From d7be2c90a152b4a2b225f4998e693aeb6dfd076f Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sat, 22 Aug 2020 09:50:37 +0200 Subject: [PATCH] Fix run() not dealing properly with coroutines --- pyrogram/methods/utilities/run.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyrogram/methods/utilities/run.py b/pyrogram/methods/utilities/run.py index dc49a524..dccce0f2 100644 --- a/pyrogram/methods/utilities/run.py +++ b/pyrogram/methods/utilities/run.py @@ -17,6 +17,7 @@ # along with Pyrogram. If not, see . import asyncio +import inspect from pyrogram.methods.utilities.idle import idle from pyrogram.scaffold import Scaffold @@ -52,6 +53,11 @@ class Run(Scaffold): if coroutine is not None: run(coroutine) else: - self.start() - run(idle()) - self.stop() + if inspect.iscoroutinefunction(self.start): + run(self.start()) + run(idle()) + run(self.stop()) + else: + self.start() + run(idle()) + self.stop()