From c30e8f9c551ce89efbef1e23cf192467ac8afdce Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Mon, 15 Jul 2019 01:26:29 +0200 Subject: [PATCH] Don't start the client in case run() is called with a coroutine as arg --- pyrogram/client/client.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) 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.