MagicStack / MagicStack/uvloop

TCP Transport RuntimeError with Python 3.13 + uvloop

Open
#685 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Cython
Stars
11.9k
Forks
616
PR merge metrics
No merged PRs in 30d

Description

TCP Transport RuntimeError with Python 3.13 + uvloop

Summary

uvloop is causing RuntimeError: unable to perform operation on <TCPTransport closed=True> errors when used with Python 3.13. Switching to --loop asyncio fixes the issue.

Environment

  • Python: 3.13.3
  • uvloop: (latest)
  • Starlette: 0.46.2
  • FastAPI: 0.115.14

Reproduction

  1. Use Python 3.13
  2. Run uvicorn with --loop uvloop
  3. Make concurrent HTTP requests (e.g., browser loading static files)
  4. Client disconnects/refreshes during response

Workaround

Use --loop asyncio instead of uvloop.

Expected

uvloop should handle closed connections gracefully like asyncio does.

Edit

I had a stray uvicorn process that had wracked up 9hrs of CPU time, this could potentially be the issue?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with Python 3.13.3, uvloop, and uvicorn using concurrent requests and a client disconnect or refresh; compare it with --loop asyncio. Trace the TCPTransport closed=True RuntimeError and account for the reported stray uvicorn process. Done means the uvloop configuration handles closed connections without this error under the reproduction.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.