Initialize asyncio event loop before using it#723
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #723 +/- ##
==========================================
- Coverage 70.55% 70.42% -0.14%
==========================================
Files 61 61
Lines 13616 14141 +525
==========================================
+ Hits 9607 9959 +352
- Misses 4009 4182 +173
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| self._qdb_connection_watch = qubesdb.QubesDB(self.name) | ||
| if loop is None: | ||
| loop = asyncio.get_event_loop() | ||
| loop = asyncio.new_event_loop() |
There was a problem hiding this comment.
During normal execution, at this point the loop surely is running already, so this change should not be necessary (or maybe it can be changed to get_running_loop()?).
What I'm not sure is there is a loop running in tests reaching this function, but this should be easy to find, and create the loop in those cases.
There was a problem hiding this comment.
Ok. I changed this one toget_running_loop.
Python 3.14 (in Fedora 43) throws RunetimeError if event loop is not initialized before using it. Resolves: QubesOS/qubes-issues#10188
cd49dc6 to
7e4a837
Compare
|
Nice contribution! What's still needed for Python 3.14? |
I am not certain. Some of the pending issues are tracked on the main Fedora 43 issue. Like this one. |
|
Thank you! |
Actually this is also ready for review. The only issue is lack of time. More information here. |
|
This PR is for dom0, and there are no plans to change Python version in R4.3 dom0 (it will stay at 3.13). This PR may be useful only for the future (R4.4 and beyond). |
|
What does may be useful mean? |
|
Yes, but at this time "main" branch is open only for changes that are necessary for R4.3. |
|
I couldn't find this information in the README, only the |
|
See https://doc.qubes-os.org/en/latest/developer/releases/version-scheme.html#release-schedule |
|
PipelineRetry |
|
openQArun MACHINE=64bit |
|
With this PR, qubesd fails to start: :( |
|
Seems to be the only place where a new loop hasn't been initialized yet: loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)Those breaking changes are surely not making it easier to use asyncio 😄 |
During qubesd startup, the event loop is already created, but it isn't running yet. Use get_event_loop(), not get_running_loop(). QubesOS/qubes-issues#10188
OpenQA test summaryComplete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026053102-devel&flavor=pull-requests Test run included the following:
New failures, excluding unstableCompared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026050504-devel&flavor=update
Failed tests56 failures
Fixed failuresCompared to: https://openqa.qubes-os.org/tests/176874#dependencies 21 fixed
Unstable testsDetails
Performance TestsPerformance degradation:26 performance degradations
Remaining performance tests:85 tests
|
|
There is a lot of failures here, most include |
If old loop still has some tasks, bad things happen (mostly timeouts waiting for no longer existing objects). While theoretically all tasks should be completed by the time test ends, ensure that by cancelling them all (and logging a warning if there were any).
Do not create new event loop for every test, that makes various FD readers and events not working anymore. While theoretically it should be possible to find and re-register them all, it isn't worth it. And also, register libvirt event loop only after creating asyncio one.
asyncio.run() unsets event loop at the end, which breaks any further use of asyncio. But the QubesTestCase.setUp() creates event loop, so using get_event_loop() is okay there. Similarly new_event_loop() is harmful. This reverts significant part of 7e4a837 "Initialize asyncio event loop before using it". Fixes: 7e4a837 "Initialize asyncio event loop before using it"
Python 3.14 (in Fedora 43) throws RunetimeError if event loop is not initialized before using it.
Resolves: QubesOS/qubes-issues#10188