mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Close bots sessions after emit_shutdown (#734)
* Close bots sessions after emit_shutdown * avoid unclosed connections if get exception in emit_shutdown * add patchnote
This commit is contained in:
parent
42cba8976f
commit
5f07cb3d06
2 changed files with 6 additions and 3 deletions
1
CHANGES/734.bugfix
Normal file
1
CHANGES/734.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Fixed bot session closing before emit shutdown
|
||||
|
|
@ -392,11 +392,13 @@ class Dispatcher(Router):
|
|||
)
|
||||
)
|
||||
await asyncio.gather(*coro_list)
|
||||
finally:
|
||||
loggers.dispatcher.info("Polling stopped")
|
||||
try:
|
||||
await self.emit_shutdown(**workflow_data)
|
||||
finally:
|
||||
for bot in bots: # Close sessions
|
||||
await bot.session.close()
|
||||
loggers.dispatcher.info("Polling stopped")
|
||||
await self.emit_shutdown(**workflow_data)
|
||||
|
||||
def run_polling(
|
||||
self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue