mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 09:22:03 +00:00
Reset webhook when need to skip updates. // executor
This commit is contained in:
parent
f050d08c75
commit
a5766aad6f
1 changed files with 5 additions and 1 deletions
|
|
@ -16,6 +16,7 @@ async def _startup(dispatcher: Dispatcher, skip_updates=False, callback=None):
|
|||
await callback(dispatcher)
|
||||
|
||||
if skip_updates:
|
||||
await dispatcher.reset_webhook(True)
|
||||
count = await dispatcher.skip_updates()
|
||||
if count:
|
||||
log.warning(f"Skipped {count} updates.")
|
||||
|
|
@ -32,6 +33,9 @@ async def _shutdown(dispatcher: Dispatcher, callback=None):
|
|||
if callable(callback):
|
||||
await callback(dispatcher)
|
||||
|
||||
if dispatcher.is_pooling():
|
||||
dispatcher.stop_pooling()
|
||||
|
||||
await dispatcher.storage.close()
|
||||
await dispatcher.storage.wait_closed()
|
||||
|
||||
|
|
@ -51,7 +55,7 @@ def start_pooling(dispatcher, *, loop=None, skip_updates=False, on_startup=None,
|
|||
|
||||
try:
|
||||
loop.run_until_complete(_startup(dispatcher, skip_updates=skip_updates, callback=on_startup))
|
||||
loop.create_task(dispatcher.start_pooling())
|
||||
loop.create_task(dispatcher.start_pooling(reset_webhook=True))
|
||||
loop.run_forever()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
pass
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue