pyTelegramBotAPI中的无限循环虽然因为空队列而出现,为什么呢?

时间:2018-07-31 17:48:49

标签: queue python-telegram-bot

pyTelegramBotAPI 3.6。,python 3.6.2

当我的代码进入无限循环时,我遇到诸如“启动循环”之类的问题。它来自utils.py in run()

DBG> decode_json $value
ERROR: Input is not UTF-8 encoded at ...

它始于:

    def run(self):
        while self._running:
            try:
                task, args, kwargs = self.queue.get(block=True, timeout=.5)
                self.continue_event.clear()
                self.received_task_event.clear()
                self.done_event.clear()
                self.exception_event.clear()
                logger.debug("Received task")
                self.received_task_event.set()

                task(*args, **kwargs)
                logger.debug("Task complete")
                self.done_event.set()
            except Queue.Empty:
                pass
            except Exception as e:
                logger.error(type(e).__name__ + " occurred, args=" + str(e.args) + "\n" + traceback.format_exc())

然后尝试:

while self._running:

然后转到:

task, args, kwargs = self.queue.get(block=True, timeout=.5)

比它偶尔重复,重复和重复...我觉得这是因为队列为空,但是为什么呢? 可能是什么问题?

0 个答案:

没有答案