python: Replace asyncio.get_event_loop for Python 3.14
PATCH v2 1/1 python: Replace asyncio.get_event_loop for Python 3.14
Updated the patch with the suggestions from Miro Hrončok & Daniel Berrangé, and retested it with Python 3.14 b4.
Rich.
PATCH v2 1/1 python: Replace asyncio.get_event_loop for Python 3.14
In Python 3.14, no asyncio event loop gets generated automatically. Instead create one when we need it. This should work with Python 3.13 as well. This change was suggested here:
https://bugzilla.redhat.com/show_bug.cgi?id=2375004#c4
See-also: https://docs.python.org/3.14/whatsnew/3.14.html#id7
Thanks: Miro Hrončok, Daniel P. Berrangé
--- python/qemu/qmp/legacy.py | 5 ++++- python/qemu/qmp/qmp_tui.py | 2 +- python/tests/protocol.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
python/qemu/qmp/legacy.py +4 -1
@@ -86,7 +86,10 @@ def __init__(self, "server argument should be False when passing a socket") self._qmp = QMPClient(nickname) - self._aloop = asyncio.get_event_loop() + try: + self._aloop = asyncio.get_event_loop() + except RuntimeError: + self._aloop = asyncio.new_event_loop() self._address = address self._timeout: Optional[float] = None
python/qemu/qmp/qmp_tui.py +1 -1
@@ -377,7 +377,7 @@ def run(self, debug: bool = False) -> None: screen = urwid.raw_display.Screen() screen.set_terminal_properties(256) - self.aloop = asyncio.get_event_loop() + self.aloop = asyncio.new_event_loop() self.aloop.set_debug(debug) # Gracefully handle SIGTERM and SIGINT signals
python/tests/protocol.py +1 -1
@@ -228,7 +228,7 @@ def async_test(async_test_method): Decorator; adds SetUp and TearDown to async tests. """ async def _wrapper(self, *args, **kwargs): - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() loop.set_debug(True) await self._asyncSetUp()
Signature · 1 line
2.50.1
Quoted 6 lines · Richard W.M. Jones
In Python 3.14, no asyncio event loop gets generated automatically. Instead create one when we need it. This should work with Python 3.13 as well. This change was suggested here:
Quoted 8 lines
See-also: https://docs.python.org/3.14/whatsnew/3.14.html#id7
Thanks: Miro Hrončok, Daniel P. BerrangéSigned-off-by Richard W.M. Jones <[email protected]>--- python/qemu/qmp/legacy.py | 5 ++++- python/qemu/qmp/qmp_tui.py | 2 +- python/tests/protocol.py | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|