1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #603 from nailerNAS/master

infinity_polling fix
This commit is contained in:
FrankWang 2019-06-28 20:57:28 +08:00 committed by GitHub
commit 56f0b0a0d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -364,12 +364,12 @@ class TeleBot:
for listener in self.update_listener:
self._exec_task(listener, new_messages)
def infinity_polling(self, *args, **kwargs):
def infinity_polling(self, timeout=20, *args, **kwargs):
while not self.__stop_polling.is_set():
try:
self.polling(*args, **kwargs)
self.polling(timeout=timeout, *args, **kwargs)
except Exception as e:
time.sleep(5)
time.sleep(timeout)
pass
logger.info("Break infinity polling")