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é <berra...@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 e11d05afbd..c6ab3edc86 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.49.0