Skip to content

Commit 6d8f52d

Browse files
committed
Added optional argument to QEventLoop constructor to indicate the event loop is already running.
1 parent 3579c5d commit 6d8f52d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

qasync/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class _QEventLoop:
257257
... loop.run_until_complete(xplusy(2, 2))
258258
"""
259259

260-
def __init__(self, app=None, set_running_loop=True):
260+
def __init__(self, app=None, set_running_loop=True, already_running=False):
261261
self.__app = app or QApplication.instance()
262262
assert self.__app is not None, 'No QApplication has been instantiated'
263263
self.__is_running = False
@@ -278,6 +278,11 @@ def __init__(self, app=None, set_running_loop=True):
278278
if set_running_loop:
279279
asyncio.events._set_running_loop(self)
280280

281+
# We have to set __is_running to True after calling
282+
# super().__init__() because of a bug in BaseEventLoop.
283+
if already_running:
284+
self.__is_running = True
285+
281286
def run_forever(self):
282287
"""Run eventloop forever."""
283288
self.__is_running = True

0 commit comments

Comments
 (0)