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:
darksidecat 2021-10-23 01:04:54 +03:00 committed by GitHub
parent 42cba8976f
commit 5f07cb3d06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

1
CHANGES/734.bugfix Normal file
View file

@ -0,0 +1 @@
Fixed bot session closing before emit shutdown

View file

@ -393,10 +393,12 @@ class Dispatcher(Router):
)
await asyncio.gather(*coro_list)
finally:
for bot in bots: # Close sessions
await bot.session.close()
loggers.dispatcher.info("Polling stopped")
await self.emit_shutdown(**workflow_data)
try:
await self.emit_shutdown(**workflow_data)
finally:
for bot in bots: # Close sessions
await bot.session.close()
def run_polling(
self,