fix [-] Exception on event loop! Task was destroyed but it is pending!

pull/138/head
ZetGo | Aleksej K. 2025-05-23 22:35:18 +03:00
parent af59cc4e50
commit 47ad704756
1 changed files with 9 additions and 7 deletions

View File

@ -972,17 +972,19 @@ class Heroku:
await asyncio.gather(*[self.amain_wrapper(client) for client in self.clients])
def _shutdown_handler(self, signum, frame):
"""Shutdown handler"""
logging.info("Bye")
for client in self.clients:
client.disconnect()
async def _shutdown_handler(self):
for t in (getattr(self, "_task", None), getattr(self, "_cleaner_task", None)):
if t: t.cancel()
await self._dp.stop_polling()
await self.bot.session.close()
for c in self.clients:
await c.disconnect()
self.loop.stop()
sys.exit(0)
def main(self):
"""Main entrypoint"""
#todosignal.signal(signal.SIGINT, self._shutdown_handler)
signal.signal(signal.SIGINT, self._shutdown_handler)
self.loop.run_until_complete(self._main())
self.loop.close()