Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions efb_telegram_master/bot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ def exception_filter(cls, exception: Exception):
@classmethod
def retry_on_timeout(cls, fn: Callable):
"""Infinitely retry for timed-out exceptions."""
if not cls.enable_retry:
return fn
cls.logger.debug("Trying to call %s with infinite retry.", fn)
return retry(wait_exponential_multiplier=1e3, wait_exponential_max=180e3,
retry_on_exception=cls.exception_filter)(fn)
@wraps(fn)
def retry_wrapper(*args, **kwargs):
# Access the instance to get the retry setting
if not cls.enable_retry:
return fn(*args, **kwargs)
cls.logger.debug("Trying to call %s with infinite retry.", fn)
retried_fn = retry(wait_exponential_multiplier=1e3, wait_exponential_max=180e3,
retry_on_exception=cls.exception_filter)(fn)
return retried_fn(*args, **kwargs)
return retry_wrapper

@classmethod
def caption_strip_class_on_failure(cls, fn: Callable):
Expand Down
Loading