avoid unclosed connections if get exception in emit_shutdown

This commit is contained in:
darksidecat 2021-10-18 01:50:49 +03:00 committed by GitHub
parent 8b9972f1ed
commit b2e76b307f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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