Skip to content

[Python 3.14t] GunicornWebWorker crashes on init when trying to close non-existent asyncio loop #11701

@Uncomfy

Description

@Uncomfy

Describe the bug

Gunicorn worker crashes on init when it tries to close event loop. Happens only in python 3.14, works correctly in 3.13

To Reproduce

  1. Implement a simple server:
from aiohttp import web

async def index(request):
    return web.Response(text="Welcome home!")

async def my_web_app():
    app = web.Application()
    app.router.add_get('/', index)
    return app
  1. Run it with gunicorn:
gunicorn my_app_module:my_web_app --bind localhost:8080 --worker-class aiohttp.GunicornWebWorker

Expected behavior

Server starts up

Logs/tracebacks

Traceback (most recent call last):
  File ".../env314t/lib/python3.14t/site-packages/gunicorn/arbiter.py", line 608, in spawn_worker
    worker.init_process()
    ~~~~~~~~~~~~~~~~~~~^^
  File ".../env314t/lib/python3.14t/site-packages/aiohttp/worker.py", line 52, in init_process
    asyncio.get_event_loop().close()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File ".../.local/share/uv/python/cpython-3.14.0+freethreaded-linux-x86_64-gnu/lib/python3.14t/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'.

Python Version

Python 3.14.0t

aiohttp Version

aiohttp 3.13.1

multidict Version

multidict 6.7.0

propcache Version

propcache 0.4.1

yarl Version

yarl 1.22.0

OS

Ubuntu 22.04

Related component

Server

Additional context

gunicorn 23.0.0

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions