From 102262dbf9cf1fd8ba12133170863af411d4fb87 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 25 Jan 2026 13:29:38 +0100 Subject: [PATCH] support/scripts/pkg-stats: fix RuntimeError with python 3.14 asyncio When running "make pkg-stats" on a host with Python 3.14 (e.g. Fedora 43 for example), the execution fails with the error: Checking URL status Traceback (most recent call last): File "/buildroot/support/scripts/pkg-stats", line 1387, in __main__() ~~~~~~~~^^ File "/buildroot/support/scripts/pkg-stats", line 1368, in __main__ loop = asyncio.get_event_loop() File "/usr/lib64/python3.14/asyncio/events.py", line 715, in get_event_loop raise RuntimeError('There is no current event loop in thread %r.' % threading.current_thread().name) RuntimeError: There is no current event loop in thread 'MainThread'. This is due to a breaking change introduced in Python 3.14 asyncio.get_event_loop(). See [1]. Before Python 3.14, this call was creating and setting an event loop if there was none. This situation is now a runtime error. In order to fix this issue with newer Python version, while keeping backward compatibility, this commit replaces the code: loop = asyncio.get_event_loop() by an explicit event loop creation: loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) This commit was tested on a Fedora 43 host with Python-3.14.2, and with the Buildroot Docker image plus the python3-aiohttp package which is a Debian 12 with Python-3.11.2. [1] https://docs.python.org/3.14/library/asyncio-eventloop.html#asyncio.get_event_loop Signed-off-by: Julien Olivain Tested-by: Vincent Fazio Signed-off-by: Thomas Petazzoni (cherry picked from commit e9f426aa527d279c078d234ffa3c4c8c052369ff) Signed-off-by: Thomas Perale --- support/scripts/pkg-stats | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats index 7d9170e30f..d2d36257d9 100755 --- a/support/scripts/pkg-stats +++ b/support/scripts/pkg-stats @@ -1365,11 +1365,13 @@ def __main__(): pkg.set_developers(developers) if "url" not in args.disable: print("Checking URL status") - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) loop.run_until_complete(check_package_urls(packages, verbose=args.verbose)) if "upstream" not in args.disable: print("Getting latest versions ...") - loop = asyncio.get_event_loop() + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) loop.run_until_complete(check_package_latest_version(packages, verbose=args.verbose)) if "cve" not in args.disable and args.nvd_path: print("Checking packages CVEs")