mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-03 11:40:11 +03:00
Fix adding events while the aio loop is stopped (#748)
This commit is contained in:
parent
abcd09e7d0
commit
b8030959b6
|
@ -2185,7 +2185,10 @@ class TelegramClient(TelegramBareClient):
|
|||
for instance ``events.NewMessage``.
|
||||
"""
|
||||
def decorator(f):
|
||||
self._loop.run_until_complete(self.add_event_handler(f, event))
|
||||
if self._loop.is_running():
|
||||
asyncio.ensure_future(self.add_event_handler(f, event))
|
||||
else:
|
||||
self._loop.run_until_complete(self.add_event_handler(f, event))
|
||||
return f
|
||||
|
||||
return decorator
|
||||
|
|
Loading…
Reference in New Issue
Block a user