From fde55a4a7f2fbd964ca51920db801e6614571e35 Mon Sep 17 00:00:00 2001 From: Dan <14043624+delivrance@users.noreply.github.com> Date: Sun, 17 Apr 2022 17:36:58 +0200 Subject: [PATCH] Improve interoperability with threads --- pyrogram/sync.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrogram/sync.py b/pyrogram/sync.py index a3e0d2b5..41c23e3b 100644 --- a/pyrogram/sync.py +++ b/pyrogram/sync.py @@ -58,7 +58,7 @@ def async_to_sync(obj, name): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) - if threading.current_thread() is threading.main_thread(): + if threading.current_thread() is threading.main_thread() or not main_loop.is_running(): if loop.is_running(): return coroutine else: