* [PULL 0/2] Python patches
@ 2025-08-20 4:58 John Snow
2025-08-20 4:58 ` [PULL 1/2] python: Replace asyncio.get_event_loop for Python 3.14 John Snow
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: John Snow @ 2025-08-20 4:58 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Peter Maydell, Michael Roth, Markus Armbruster,
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 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(-)
--
2.50.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PULL 1/2] python: Replace asyncio.get_event_loop for Python 3.14
2025-08-20 4:58 [PULL 0/2] Python patches John Snow
@ 2025-08-20 4:58 ` John Snow
2025-08-20 4:58 ` [PULL 2/2] python: avoid deprecation warning with get_event_loop John Snow
2025-08-20 5:01 ` [PULL 0/2] Python patches John Snow
2 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2025-08-20 4:58 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Peter Maydell, Michael Roth, Markus Armbruster,
John Snow, Richard W.M. Jones
From: "Richard W.M. Jones" <rjones@redhat.com>
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é
Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
---
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(-)
diff --git a/python/qemu/qmp/legacy.py b/python/qemu/qmp/legacy.py
index 22a2b5616ef..e11d05afbd6 100644
--- a/python/qemu/qmp/legacy.py
+++ b/python/qemu/qmp/legacy.py
@@ -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
diff --git a/python/qemu/qmp/qmp_tui.py b/python/qemu/qmp/qmp_tui.py
index 2d9ebbd20bc..7dfb03c9ad5 100644
--- a/python/qemu/qmp/qmp_tui.py
+++ b/python/qemu/qmp/qmp_tui.py
@@ -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
diff --git a/python/tests/protocol.py b/python/tests/protocol.py
index 56c4d441f9c..db5d54d83f4 100644
--- a/python/tests/protocol.py
+++ b/python/tests/protocol.py
@@ -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()
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PULL 2/2] python: avoid deprecation warning with get_event_loop
2025-08-20 4:58 [PULL 0/2] Python patches John Snow
2025-08-20 4:58 ` [PULL 1/2] python: Replace asyncio.get_event_loop for Python 3.14 John Snow
@ 2025-08-20 4:58 ` John Snow
2025-08-20 5:01 ` [PULL 0/2] Python patches John Snow
2 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2025-08-20 4:58 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Peter Maydell, Michael Roth, Markus Armbruster,
John Snow, Daniel P. Berrangé, Eric Blake
From: Daniel P. Berrangé <berrange@redhat.com>
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.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
---
python/qemu/qmp/legacy.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/python/qemu/qmp/legacy.py b/python/qemu/qmp/legacy.py
index e11d05afbd6..c6ab3edc867 100644
--- a/python/qemu/qmp/legacy.py
+++ b/python/qemu/qmp/legacy.py
@@ -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
--
2.50.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PULL 0/2] Python patches
2025-08-20 4:58 [PULL 0/2] Python patches John Snow
2025-08-20 4:58 ` [PULL 1/2] python: Replace asyncio.get_event_loop for Python 3.14 John Snow
2025-08-20 4:58 ` [PULL 2/2] python: avoid deprecation warning with get_event_loop John Snow
@ 2025-08-20 5:01 ` John Snow
2025-08-20 13:33 ` Daniel P. Berrangé
2 siblings, 1 reply; 5+ messages in thread
From: John Snow @ 2025-08-20 5:01 UTC (permalink / raw)
To: qemu-devel, Daniel Berrangé
Cc: Cleber Rosa, Peter Maydell, Michael Roth, Markus Armbruster
On Wed, Aug 20, 2025 at 12:58 AM John Snow <jsnow@redhat.com> wrote:
>
> 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(-)
>
> --
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PULL 0/2] Python patches
2025-08-20 5:01 ` [PULL 0/2] Python patches John Snow
@ 2025-08-20 13:33 ` Daniel P. Berrangé
0 siblings, 0 replies; 5+ messages in thread
From: Daniel P. Berrangé @ 2025-08-20 13:33 UTC (permalink / raw)
To: John Snow
Cc: qemu-devel, Cleber Rosa, Peter Maydell, Michael Roth,
Markus Armbruster
On Wed, Aug 20, 2025 at 01:01:06AM -0400, John Snow wrote:
> On Wed, Aug 20, 2025 at 12:58 AM John Snow <jsnow@redhat.com> wrote:
> >
> > 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(-)
> >
> > --
> > 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.
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
--
|: 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 :|
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-08-20 13:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 4:58 [PULL 0/2] Python patches John Snow
2025-08-20 4:58 ` [PULL 1/2] python: Replace asyncio.get_event_loop for Python 3.14 John Snow
2025-08-20 4:58 ` [PULL 2/2] python: avoid deprecation warning with get_event_loop John Snow
2025-08-20 5:01 ` [PULL 0/2] Python patches John Snow
2025-08-20 13:33 ` Daniel P. Berrangé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).