Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Optional argument to QEventLoop constructor for already running loops #29

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion asyncqt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class _QEventLoop:
... loop.run_until_complete(xplusy(2, 2))
"""

def __init__(self, app=None, set_running_loop=True):
def __init__(self, app=None, set_running_loop=True, already_running=False):
self.__app = app or QApplication.instance()
assert self.__app is not None, 'No QApplication has been instantiated'
self.__is_running = False
Expand All @@ -276,6 +276,11 @@ def __init__(self, app=None, set_running_loop=True):
if set_running_loop:
asyncio.events._set_running_loop(self)

# We have to set __is_running to True after calling
# super().__init__() because of a bug in BaseEventLoop.
if already_running:
self.__is_running = True

def run_forever(self):
"""Run eventloop forever."""
self.__is_running = True
Expand Down