Python patches
The following changes since commit 5836af0783213b9355a6bbf85d9e6bc4c9c9363f:
Merge tag 'uefi-20250812-pull-request' of https://gitlab.com/kraxel/qemu into staging (2025-08-13 15:19:29 -0400)
are available in the Git repository at:
https://gitlab.com/jsnow/qemu.git tags/python-pull-request
for you to fetch changes up to 16398e73cd13c7d9f284d8ec4a440778fc2e3f9a:
python: avoid deprecation warning with get_event_loop (2025-08-20 00:55:27 -0400)
----------------------------------------------------------------
Python pull request
Necessary for Python 3.14 support for iotests, releasing October 7th
----------------------------------------------------------------
Daniel P. Berrangé (1):
python: avoid deprecation warning with get_event_loop
Richard W.M. Jones (1):
python: Replace asyncio.get_event_loop for Python 3.14
python/qemu/qmp/legacy.py | 10 +++++++++- python/qemu/qmp/qmp_tui.py | 2 +- python/tests/protocol.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)
Signature · 1 line
2.50.1
[PULL 1/2] python: Replace asyncio.get_event_loop for Python 3.14
From: "Richard W.M. Jones" <[email protected]>
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
[PULL 2/2] python: avoid deprecation warning with get_event_loop
In reply to John SnowFrom: Daniel P. Berrangé <[email protected]>
We need to call get_event_loop but have no way of knowing ahead of time whether the current thread has an event loop of not. We can handle a missing event loop, but we need to hide the warning python will emit to avoid tripping up iotests expected output.
--- python/qemu/qmp/legacy.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
python/qemu/qmp/legacy.py +6 -1
@@ -34,6 +34,7 @@ TypeVar, Union, ) +import warnings from .error import QMPError from .protocol import Runstate, SocketAddrT
@@ -87,7 +88,11 @@ def __init__(self, self._qmp = QMPClient(nickname) try: - self._aloop = asyncio.get_event_loop() + with warnings.catch_warnings(): + # Python <= 3.13 will trigger deprecation warnings + # if no event loop is set + warnings.simplefilter("ignore") + self._aloop = asyncio.get_event_loop() except RuntimeError: self._aloop = asyncio.new_event_loop() self._address = address
Signature · 1 line
2.50.1
Quoted 26 lines · John Snow
The following changes since commit
5836af0783213b9355a6bbf85d9e6bc4c9c9363f:Merge tag 'uefi-20250812-pull-request' of https://gitlab.com/kraxel/qemu into staging (2025-08-13 15:19:29 -0400)
are available in the Git repository at:
https://gitlab.com/jsnow/qemu.git tags/python-pull-request
for you to fetch changes up to
16398e73cd13c7d9f284d8ec4a440778fc2e3f9a:python: avoid deprecation warning with
get_event_loop(2025-08-20 00:55:27 -0400)----------------------------------------------------------------
Python pull requestNecessary for Python 3.14 support for iotests, releasing October 7th
----------------------------------------------------------------
Daniel P. Berrangé (1):
python: avoid deprecation warning withget_event_loopRichard W.M. Jones (1):
python: Replace asyncio.get_event_loop for Python 3.14
Quoted 8 lines
python/qemu/qmp/legacy.py | 10 +++++++++- python/qemu/qmp/qmp_tui.py | 2 +- python/tests/protocol.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)--
2.50.1
Dan: I wasn't sure if you were suggesting these to be pulled *right away*, but just in case that is what you meant, I sent this PR for what I think is the minimum necessary to avoid iotests croaking when 3.14 drops in October. Let me know if we need to make any other adjustments here and I will follow up in the morning.
Quoted 36 lines · John Snow
Quoted 26 lines · John Snow
The following changes since commit
5836af0783213b9355a6bbf85d9e6bc4c9c9363f:Merge tag 'uefi-20250812-pull-request' of https://gitlab.com/kraxel/qemu into staging (2025-08-13 15:19:29 -0400)
are available in the Git repository at:
https://gitlab.com/jsnow/qemu.git tags/python-pull-request
for you to fetch changes up to
16398e73cd13c7d9f284d8ec4a440778fc2e3f9a:python: avoid deprecation warning with
get_event_loop(2025-08-20 00:55:27 -0400)----------------------------------------------------------------
Python pull requestNecessary for Python 3.14 support for iotests, releasing October 7th
----------------------------------------------------------------
Daniel P. Berrangé (1):
python: avoid deprecation warning withget_event_loopRichard W.M. Jones (1):
python: Replace asyncio.get_event_loop for Python 3.14Quoted 8 lines
python/qemu/qmp/legacy.py | 10 +++++++++- python/qemu/qmp/qmp_tui.py | 2 +- python/tests/protocol.py | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)--
2.50.1
Quoted 5 lines
Dan: I wasn't sure if you were suggesting these to be pulled *right away*, but just in case that is what you meant, I sent this PR for what I think is the minimum necessary to avoid iotests croaking when 3.14 drops in October. Let me know if we need to make any other adjustments here and I will follow up in the morning.
Only the 1st patch is important for the 10.1.0 release - the 2nd patch doesn't take effect until the rest of my py series that explicitly turns on warnings for iotests/functional tests.
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 :|