mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added log message when connection is established in polling process
This commit is contained in:
parent
2e69100e1b
commit
4dbf69cd18
1 changed files with 10 additions and 1 deletions
|
|
@ -193,10 +193,12 @@ class Dispatcher(Router):
|
|||
# Request timeout can be lower than session timeout and that's OK.
|
||||
# To prevent false-positive TimeoutError we should wait longer than polling timeout
|
||||
kwargs["request_timeout"] = int(bot.session.timeout + polling_timeout)
|
||||
failed = False
|
||||
while True:
|
||||
try:
|
||||
updates = await bot(get_updates, **kwargs)
|
||||
except Exception as e:
|
||||
failed = True
|
||||
# In cases when Telegram Bot API was inaccessible don't need to stop polling
|
||||
# process because some developers can't make auto-restarting of the script
|
||||
loggers.dispatcher.error("Failed to fetch updates - %s: %s", type(e).__name__, e)
|
||||
|
|
@ -212,7 +214,14 @@ class Dispatcher(Router):
|
|||
|
||||
# In case when network connection was fixed let's reset the backoff
|
||||
# to initial value and then process updates
|
||||
backoff.reset()
|
||||
if failed:
|
||||
loggers.dispatcher.info(
|
||||
"Connection established (tryings = %d, bot id = %d)",
|
||||
backoff.counter,
|
||||
bot.id,
|
||||
)
|
||||
backoff.reset()
|
||||
failed = False
|
||||
|
||||
for update in updates:
|
||||
yield update
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue