summary refs log tree commit diff stats
path: root/python/qemu/qmp/qmp_tui.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/qemu/qmp/qmp_tui.py')
-rw-r--r--python/qemu/qmp/qmp_tui.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python/qemu/qmp/qmp_tui.py b/python/qemu/qmp/qmp_tui.py
index 53ea6c59a7..12bdc17c99 100644
--- a/python/qemu/qmp/qmp_tui.py
+++ b/python/qemu/qmp/qmp_tui.py
@@ -388,7 +388,12 @@ class App(QMPClient):
         screen = urwid.raw_display.Screen()
         screen.set_terminal_properties(256)
 
-        self.aloop = asyncio.get_event_loop()
+        try:
+            self.aloop = asyncio.get_running_loop()
+        except RuntimeError:
+            # No running asyncio event loop. Create one if necessary.
+            self.aloop = asyncio.get_event_loop_policy().get_event_loop()
+
         self.aloop.set_debug(debug)
 
         # Gracefully handle SIGTERM and SIGINT signals