mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Fix Bot.__del__ for cases when event loop is closed
This commit is contained in:
parent
7fb21ead9d
commit
bd90c726b5
1 changed files with 5 additions and 2 deletions
|
|
@ -100,10 +100,13 @@ class BaseBot:
|
||||||
self.parse_mode = parse_mode
|
self.parse_mode = parse_mode
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
if not hasattr(self, 'loop'):
|
||||||
|
return
|
||||||
if self.loop.is_running():
|
if self.loop.is_running():
|
||||||
self.loop.create_task(self.close())
|
self.loop.create_task(self.close())
|
||||||
else:
|
return
|
||||||
self.loop.run_until_complete(self.close())
|
loop = asyncio.new_event_loop()
|
||||||
|
loop.run_until_complete(self.close())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _prepare_timeout(
|
def _prepare_timeout(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue