CabbageDevelopment / qasync

Python library for using asyncio in Qt-based applications.
BSD 2-Clause "Simplified" License
334 stars 45 forks source link

Correct loop pre/postprocessing with already_running #31

Closed ickby closed 3 years ago

ickby commented 3 years ago

The event loop implementations need some pre- and post processing to correctly work. This is currently not done in case an already running QApplication is used. The provided commit changes that. Furthermore it forbids to run the default loop entry points when the loop is already running, to prevent wrong usage after initialization with an running QApplication.

Note: The postprocessing of the event loop needs to happen on application closing, as this is the behavior when using run_forever/run_until_complete. I opted to use the applications aboutToQuit signal to trigger this action, but mostly as I had no other working idea. Seems not very elegant. Please carefully review this implementation.

Fixes #30

TheGreatCabbage commented 3 years ago

This looks promising, I'll try to review and merge it over the weekend. Sorry for the late response!

ickby commented 3 years ago

Closed by referenced commit. Thanks for adding the change!

TheGreatCabbage commented 3 years ago

Thanks for the contribution!