dispatcher.py 文件源码

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

项目:deluge-telegramer 作者: noam09 项目源码 文件源码
def start(self):
        """Thread target of thread 'dispatcher'.

        Runs in background and processes the update queue.

        """
        if self.running:
            self.logger.warning('already running')
            return

        if self.__exception_event.is_set():
            msg = 'reusing dispatcher after exception event is forbidden'
            self.logger.error(msg)
            raise TelegramError(msg)

        self._init_async_threads(uuid4(), self.workers)
        self.running = True
        self.logger.debug('Dispatcher started')

        while 1:
            try:
                # Pop update from update queue.
                update = self.update_queue.get(True, 1)
            except Empty:
                if self.__stop_event.is_set():
                    self.logger.debug('orderly stopping')
                    break
                elif self.__exception_event.is_set():
                    self.logger.critical('stopping due to exception in another thread')
                    break
                continue

            self.logger.debug('Processing Update: %s' % update)
            self.process_update(update)

        self.running = False
        self.logger.debug('Dispatcher thread stopped')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号