Skip to content

Optional argument to QEventLoop constructor for already running loops #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

zerotypic
Copy link
Contributor

In certain situations, Python is running in an environment where the event loop as already been started. For example when Python is embedded as a scripting language within another application. As such, when creating a QEventLoop, we need to be able to set __is_running to True. I added an optional argument to the constructor that lets us do this.

The value if __is_running is set only after the superclass's constructor is called, because I found a bug in asyncio's BaseEventLoop: an exception occurs during initialization if the event loop reports it is already running. I'll be submitting a patch for that to the asyncio maintainers. In the meantime, setting __is_running at the end of QEventLoop's constructor seems to work fine.

Note: This is identical to a PR I put up for asyncqt here: gmarull/asyncqt#29

@TheGreatCabbage TheGreatCabbage merged commit bddac58 into CabbageDevelopment:master Nov 11, 2020
@TheGreatCabbage
Copy link
Member

TheGreatCabbage commented Nov 11, 2020

Nice work, thanks for your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants