diff --git a/pyrogram/client/client.py b/pyrogram/client/client.py index 35902611..c1065a42 100644 --- a/pyrogram/client/client.py +++ b/pyrogram/client/client.py @@ -17,7 +17,6 @@ # along with Pyrogram. If not, see . import asyncio -import inspect import logging import math import mimetypes @@ -452,21 +451,17 @@ class Client(Methods, BaseClient): loop = asyncio.get_event_loop() run = loop.run_until_complete - run(self.start()) + if coroutine is not None: + run(coroutine) + else: + run(self.start()) + run(self.idle()) - run( - coroutine if inspect.iscoroutine(coroutine) - else coroutine() if coroutine - else self.idle() - ) - - if self.is_started: - run(self.stop()) + # TODO: Uncomment this once idle() gets refactored + # run(self.stop()) loop.close() - return coroutine - def add_handler(self, handler: Handler, group: int = 0): """Register an update handler.