def _run(self):
"""
Read from the work_queue, process it using an NNTPRequest object.
"""
# block until we have an event to handle.
# print "Worker %s ready!" % self
while not self._exit.is_set():
# Begin our loop
try:
request = self._work_queue.get()
if request is StopIteration:
# during a close() call (defined below) we force
# a StopIteration into the queue to force an exit
# from a program level
return
if request.is_set():
# Process has been aborted or is no longer needed
continue
except StopIteration:
# Got Exit
return
except EmptyQueueException:
# Nothing available for us
continue
# Mark ourselves busy
self._work_tracker.mark_busy(self)
# If we reach here, we have a request to process
request.run(connection=self._connection)
# Mark ourselves available again
self._work_tracker.mark_available(self)
# Ensure our connection is closed before we exit
self._connection.close()
评论列表
文章目录