Fix adding events while the aio loop is stopped (#748)

This commit is contained in:
Dan Elkouby 2018-04-08 01:05:16 +03:00 committed by Lonami
parent abcd09e7d0
commit b8030959b6

View File

@ -2185,6 +2185,9 @@ class TelegramClient(TelegramBareClient):
for instance ``events.NewMessage``.
"""
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))
return f