mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Added an incremental sleep when an error is encountered while polling
This commit is contained in:
parent
d118e9edcc
commit
6f34a22c4b
@ -161,13 +161,19 @@ class TeleBot:
|
||||
|
||||
def __polling(self, none_stop, interval):
|
||||
logger.info('TeleBot: Started polling.')
|
||||
|
||||
error_interval = .25
|
||||
while not self.__stop_polling.wait(interval):
|
||||
try:
|
||||
self.get_update()
|
||||
except Exception as e:
|
||||
error_interval = .25
|
||||
except apihelper.ApiException as e:
|
||||
if not none_stop:
|
||||
self.__stop_polling.set()
|
||||
logger.info("TeleBot: Exception occurred. Stopping.")
|
||||
else:
|
||||
time.sleep(error_interval)
|
||||
error_interval *= 2
|
||||
logger.error(e)
|
||||
|
||||
logger.info('TeleBot: Stopped polling.')
|
||||
|
Loading…
Reference in New Issue
Block a user