def poll(self):
"""
Message polling process.
"""
self.polling_from_tg()
while True:
try:
m = self.queue.get()
if m is None:
break
self.logger.info("Got message from queue\nType: %s\nText: %s\n----" % (m.type, m.text))
threading.Thread(target=self.process_msg, args=(m,)).start()
self.queue.task_done()
self.logger.info("Msg sent to TG, task_done marked.")
except Exception as e:
self.logger.error("Error occurred during message polling")
self.logger.error(repr(e))
self.bot.stop()
self.poll()
self.logger.debug("Gracefully stopping %s (%s).", self.channel_name, self.channel_id)
self.bot.stop()
self.logger.debug("%s (%s) gracefully stopped.", self.channel_name, self.channel_id)
评论列表
文章目录