From 47d8edc0fcafcfdbab1a334e19ad45ce3b7eafb9 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 13 Dec 2023 10:03:11 +0800 Subject: [PATCH] test.py: s/asyncio.get_event_loop()/asyncio.get_running_loop()/ the latter raises a RuntimeError if there is no no running event loop, while the former gets one from the the default policy in this case. in the use cases in test.py, there is always a running event loop, when `asyncio.get_event_loop()` gets called. so let's use the preferred `asyncio.get_running_loop()`. see https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop Signed-off-by: Kefu Chai Closes scylladb/scylladb#16398 --- test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index ac685ee3ea..6d872c09e2 100755 --- a/test.py +++ b/test.py @@ -1576,7 +1576,7 @@ async def main() -> int: signaled = asyncio.Event() - setup_signal_handlers(asyncio.get_event_loop(), signaled) + setup_signal_handlers(asyncio.get_running_loop(), signaled) try: await run_all_tests(signaled, options) @@ -1616,10 +1616,10 @@ async def workaround_python26789() -> int: except (Exception, KeyboardInterrupt): def noop(x, y): return None - asyncio.get_event_loop().set_exception_handler(noop) + asyncio.get_running_loop().set_exception_handler(noop) traceback.print_exc() # Clear the custom handler - asyncio.get_event_loop().set_exception_handler(None) + asyncio.get_running_loop().set_exception_handler(None) return -1 return code