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:
parent
87574a7613
commit
82838e1d26
@ -6,6 +6,7 @@ import re
|
|||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
logger = logging.getLogger('TeleBot')
|
logger = logging.getLogger('TeleBot')
|
||||||
formatter = logging.Formatter(
|
formatter = logging.Formatter(
|
||||||
@ -459,7 +460,8 @@ class TeleBot:
|
|||||||
try:
|
try:
|
||||||
self.polling(none_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout, *args, **kwargs)
|
self.polling(none_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout, *args, **kwargs)
|
||||||
except Exception as e:
|
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)
|
time.sleep(3)
|
||||||
continue
|
continue
|
||||||
logger.info("Infinity polling: polling exited")
|
logger.info("Infinity polling: polling exited")
|
||||||
|
@ -254,7 +254,7 @@ def get_updates(token, offset=None, limit=None, timeout=None, allowed_updates=No
|
|||||||
if limit:
|
if limit:
|
||||||
payload['limit'] = limit
|
payload['limit'] = limit
|
||||||
if timeout:
|
if timeout:
|
||||||
payload['timeout'] = timeout
|
payload['connect-timeout'] = timeout
|
||||||
if long_polling_timeout:
|
if long_polling_timeout:
|
||||||
payload['long_polling_timeout'] = long_polling_timeout
|
payload['long_polling_timeout'] = long_polling_timeout
|
||||||
if allowed_updates is not None: # Empty lists should pass
|
if allowed_updates is not None: # Empty lists should pass
|
||||||
|
@ -235,8 +235,10 @@ def or_clear(self):
|
|||||||
|
|
||||||
|
|
||||||
def orify(e, changed_callback):
|
def orify(e, changed_callback):
|
||||||
e._set = e.set
|
if not hasattr(e, "_set"):
|
||||||
e._clear = e.clear
|
e._set = e.set
|
||||||
|
if not hasattr(e, "_clear"):
|
||||||
|
e._clear = e.clear
|
||||||
e.changed = changed_callback
|
e.changed = changed_callback
|
||||||
e.set = lambda: or_set(e)
|
e.set = lambda: or_set(e)
|
||||||
e.clear = lambda: or_clear(e)
|
e.clear = lambda: or_clear(e)
|
||||||
@ -244,7 +246,7 @@ def orify(e, changed_callback):
|
|||||||
def OrEvent(*events):
|
def OrEvent(*events):
|
||||||
or_event = threading.Event()
|
or_event = threading.Event()
|
||||||
def changed():
|
def changed():
|
||||||
bools = [e.is_set() for e in events]
|
bools = [ev.is_set() for ev in events]
|
||||||
if any(bools):
|
if any(bools):
|
||||||
or_event.set()
|
or_event.set()
|
||||||
else:
|
else:
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Versions should comply with PEP440.
|
# Versions should comply with PEP440.
|
||||||
# This line is parsed in setup.py:
|
# This line is parsed in setup.py:
|
||||||
__version__ = '3.7.5'
|
__version__ = '3.7.5.u1'
|
||||||
|
Loading…
Reference in New Issue
Block a user