From c7de3f48b5d1b90efb569517ae670ddb684f650c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Sun, 1 Nov 2026 23:10:53 +0000 Subject: [PATCH] Fix RuntimeError from asyncio.get_event_loop() on Python 3.14+ Since Python 3.14, asyncio.get_event_loop() raises RuntimeError when there is no current event loop in the thread, instead of creating one. Every Celery task has been failing with this since the Docker image moved from python:3.11-slim to python:3.15-slim in #751: RuntimeError: There is no current event loop in thread 'MainThread'. Use asyncio.run() instead, which creates and tears down a loop per task call. --- miss_islington/tasks.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/miss_islington/tasks.py b/miss_islington/tasks.py index 42d45ec9..83226d5f 100644 --- a/miss_islington/tasks.py +++ b/miss_islington/tasks.py @@ -80,8 +80,7 @@ def setup_cpython_repo(): @app.task() def backport_task(commit_hash, branch, *, issue_number, created_by, merged_by, installation_id): - loop = asyncio.get_event_loop() - loop.run_until_complete( + asyncio.run( backport_task_asyncio( commit_hash, branch, @@ -262,8 +261,7 @@ async def backport_task_asyncio( @app.task() def delete_branch_task(branch_name, pr_url, merged, *, installation_id): """Delete a branch from the miss-islington/cpython fork.""" - loop = asyncio.get_event_loop() - loop.run_until_complete( + asyncio.run( _delete_branch_task_asyncio( branch_name, pr_url, merged, installation_id=installation_id )