NNTPManager.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:newsreap 作者: caronc 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号