From 786851078e4e3e4ec319870b231b5cc8f8e4d405 Mon Sep 17 00:00:00 2001 From: Ewald de Wit Date: Fri, 28 Jul 2023 09:57:17 +0200 Subject: [PATCH] Simplify run() method --- nest_asyncio.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nest_asyncio.py b/nest_asyncio.py index 21cf7ca..4459699 100644 --- a/nest_asyncio.py +++ b/nest_asyncio.py @@ -24,12 +24,7 @@ def _patch_asyncio(): """Patch asyncio module to use pure Python tasks and futures.""" def run(main, *, debug=False): - try: - loop = asyncio.get_event_loop() - except RuntimeError: - loop = asyncio.new_event_loop() - asyncio.set_event_loop(loop) - _patch_loop(loop) + loop = asyncio.get_event_loop() loop.set_debug(debug) task = asyncio.ensure_future(main) try: