Skip to content

DeprecationWarning “There is no current event loop” raised on Mangum init (asyncio.get_event_loop) in 0.21.0 #377

@Owen-OptiGrid

Description

@Owen-OptiGrid

After upgrading from mangum==0.20.0 to 0.21.0, we now get:

DeprecationWarning: There is no current event loop asyncio.get_event_loop()

This appears to come from Mangum.init calling _setup_event_loop() (added in 0.21.0), which calls asyncio.get_event_loop() when no loop is set.

I have pytest set to fail tests on warnings so noticed upgrading to mangum 0.21.0 caused test failures

Repro:

Python 3.13+

from fastapi import FastAPI
from mangum import Mangum

app = FastAPI()
handler = Mangum(app)  # emits DeprecationWarning

Expected:

No DeprecationWarning during adapter construction.

Actual:

DeprecationWarning emitted on import/initialization.

Notes:

  • In 0.20.0, adapter.py does not call get_event_loop().
  • This warning is treated as error in test environments, so it breaks our CI.

Environment:

  • mangum 0.21.0
  • Python 3.13 (also likely 3.12 with default warnings enabled)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions