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

Infinity polling fall down fixed

This commit is contained in:
Badiboy 2021-01-14 03:44:37 +03:00
parent 87574a7613
commit 82838e1d26
4 changed files with 10 additions and 6 deletions

View File

@ -6,6 +6,7 @@ import re
import sys
import threading
import time
import traceback
logger = logging.getLogger('TeleBot')
formatter = logging.Formatter(
@ -459,7 +460,8 @@ class TeleBot:
try:
self.polling(none_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout, *args, **kwargs)
except Exception as e:
logger.error("Infinity polling exception: {}".format(e))
logger.error("Infinity polling exception: %s", str(e))
logger.debug("Exception traceback:\n%s", traceback.format_exc())
time.sleep(3)
continue
logger.info("Infinity polling: polling exited")

View File

@ -254,7 +254,7 @@ def get_updates(token, offset=None, limit=None, timeout=None, allowed_updates=No
if limit:
payload['limit'] = limit
if timeout:
payload['timeout'] = timeout
payload['connect-timeout'] = timeout
if long_polling_timeout:
payload['long_polling_timeout'] = long_polling_timeout
if allowed_updates is not None: # Empty lists should pass

View File

@ -235,8 +235,10 @@ def or_clear(self):
def orify(e, changed_callback):
e._set = e.set
e._clear = e.clear
if not hasattr(e, "_set"):
e._set = e.set
if not hasattr(e, "_clear"):
e._clear = e.clear
e.changed = changed_callback
e.set = lambda: or_set(e)
e.clear = lambda: or_clear(e)
@ -244,7 +246,7 @@ def orify(e, changed_callback):
def OrEvent(*events):
or_event = threading.Event()
def changed():
bools = [e.is_set() for e in events]
bools = [ev.is_set() for ev in events]
if any(bools):
or_event.set()
else:

View File

@ -1,3 +1,3 @@
# Versions should comply with PEP440.
# This line is parsed in setup.py:
__version__ = '3.7.5'
__version__ = '3.7.5.u1'