From ac1aafc9f13ffad7e903b95332ac789abdd6f9dc Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Fri, 4 Feb 2022 16:51:31 +0800 Subject: [PATCH] use asyncio.get_event_loop() for Python < 3.10 fixes #207. --- nvchecker/__main__.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nvchecker/__main__.py b/nvchecker/__main__.py index 6e812fc..31f5ca5 100755 --- a/nvchecker/__main__.py +++ b/nvchecker/__main__.py @@ -78,7 +78,12 @@ def main() -> None: result_coro = core.process_result(oldvers, result_q, entry_waiter) runner_coro = core.run_tasks(futures) - newvers, has_failures = asyncio.run(run(result_coro, runner_coro)) + if sys.version_info >= (3, 10): + # Python 3.10 has deprecated asyncio.get_event_loop + newvers, has_failures = asyncio.run(run(result_coro, runner_coro)) + else: + # Python < 3.10 will create an eventloop when asyncio.Queue is initialized + newvers, has_failures = asyncio.get_event_loop().run_until_complete(run(result_coro, runner_coro)) if options.ver_files is not None: core.write_verfile(options.ver_files[1], newvers)