Initialize asyncio event loop before using it#821
Conversation
Python 3.14 (in Fedora 43) throws RunetimeError if event loop is not initialized before using it. Note most uses of get_event_loop() (especially in tests) are okay, since event loop already exists at that point, even if it isn't running at that moment. There is also caveat about using asyncio.run() - it resets event loop at the end, which breaks any further use of asyncio. It's okay to use it in main function of a standalone tool, but it's not okay in utility function or tests. And finally, register libvirt event loop only after creating asyncio one. Fixes: QubesOS/qubes-issues#10188 Fixes: QubesOS/qubes-issues#10820
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).
f2a0cf8 to
125cb5a
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #821 +/- ##
==========================================
- Coverage 70.42% 70.42% -0.01%
==========================================
Files 61 61
Lines 14143 14112 -31
==========================================
- Hits 9960 9938 -22
+ Misses 4183 4174 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
OpenQA test summaryComplete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2026060401-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 tests24 failures
Fixed failuresCompared to: https://openqa.qubes-os.org/tests/176874#dependencies 16 fixed
Unstable testsDetails
Performance TestsPerformance degradation:23 performance degradations
Remaining performance tests:88 tests
|
Python 3.14 (in Fedora 43) throws RunetimeError if event loop is not
initialized before using it.
Note most uses of get_event_loop() (especially in tests) are okay, since
event loop already exists at that point, even if it isn't running at
that moment.
There is also caveat about using asyncio.run() - it resets event loop at
the end, which breaks any further use of asyncio. It's okay to use it in
main function of a standalone tool, but it's not okay in utility
function or tests.
And finally, register libvirt event loop only after creating asyncio one.
Fixes: QubesOS/qubes-issues#10188
Fixes: QubesOS/qubes-issues#10820