Skip to content

Fix RuntimeError from asyncio.get_event_loop() on Python 3.14+ - #755

Merged
Mariatta merged 1 commit into
mainfrom
fix-get-event-loop
Nov 1, 2026
Merged

Mariatta merged 1 commit into
mainfrom
fix-get-event-loop

Conversation

@hugovk

@hugovk hugovk commented Nov 1, 2026

Copy link
Copy Markdown
Member

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.

Docs:

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.
@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c9f9fc9) to head (c7de3f4).

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #755   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines          366       366           
  Branches        12        12           
=========================================
  Hits           366       366           
Flag Coverage Δ
Python_3.14 100.00% <ø> (ø)
Python_3.15 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Mariatta
Mariatta merged commit 7fbe32f into main Nov 1, 2026
11 checks passed
@Mariatta
Mariatta deleted the fix-get-event-loop branch November 1, 2026 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants