mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 20:50:22 +03:00
Fix adding events while the aio loop is stopped (#748)
This commit is contained in:
parent
abcd09e7d0
commit
b8030959b6
|
@ -2185,6 +2185,9 @@ class TelegramClient(TelegramBareClient):
|
||||||
for instance ``events.NewMessage``.
|
for instance ``events.NewMessage``.
|
||||||
"""
|
"""
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
|
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))
|
self._loop.run_until_complete(self.add_event_handler(f, event))
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user