From c87a4d3476ea36d72bcbb35df63b22ad5053df2b Mon Sep 17 00:00:00 2001 From: hibobmaster Date: Tue, 7 Mar 2023 22:11:16 +0800 Subject: [PATCH] prefer asyncio.get_event_loop instead of asyncio.new_event_loop --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index d780bbf..5e5f0e8 100644 --- a/main.py +++ b/main.py @@ -20,9 +20,9 @@ async def main(): if __name__ == "__main__": try: - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - asyncio.run(main()) + loop = asyncio.get_event_loop() + task = loop.create_task(main()) + loop.run_until_complete(task) except KeyboardInterrupt: loop.close() sys.exit(0)