Skip to content

Commit d7be2c9

Browse files
committed
Fix run() not dealing properly with coroutines
1 parent bc62b3f commit d7be2c9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • pyrogram/methods/utilities

pyrogram/methods/utilities/run.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import asyncio
20+
import inspect
2021

2122
from pyrogram.methods.utilities.idle import idle
2223
from pyrogram.scaffold import Scaffold
@@ -52,6 +53,11 @@ def run(self, coroutine=None):
5253
if coroutine is not None:
5354
run(coroutine)
5455
else:
55-
self.start()
56-
run(idle())
57-
self.stop()
56+
if inspect.iscoroutinefunction(self.start):
57+
run(self.start())
58+
run(idle())
59+
run(self.stop())
60+
else:
61+
self.start()
62+
run(idle())
63+
self.stop()

0 commit comments

Comments
 (0)