Allow context for tasks that block the event loop
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- backend, observability
Direzione di ricerca
Inizia leggendo le righe 268-273 di uvloop/cbhandles.pyx e confronta il comportamento di debug slow-log con l'implementazione di asyncio, usando la riproduzione FastAPI in server.py con PYTHONASYNCIODEBUG=1. L'issue non definisce un output o un'implementazione accettati, quindi chiarisci il contesto desiderato e il comportamento dello stack trace prima di scrivere il codice.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hi all,
This is probably more of a discussion than an actual issue and I fully appreciate that this could be more of a Python asyncio question versus anything specific to uvloop's implementation (I've also started a discussion there), but I figured I'd ask here first because uvloop is wonderful and you all clearly have a deep understanding of creating an event loop implementation in Python.
My issue is this: when debug mode is enabled for the Python event loop, is it somehow possible to get slow logs to tell us more about the context the task is running in?
The motivation is that in many asyncio server frameworks like FastAPI, it is critical to not block the event loop but using asyncio's debug mode provides output that's not helpful.
Consider the following FastAPI server:
# server.py
# run with PYTHONASYNCIODEBUG=1 uvicorn server:app --reload --port 8000 --host 0.0.0.0
import time
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
async def root():
time.sleep(2) # intentionally block event loop for 2 seconds
return {"message": "Hello World"}
If you curl http://127.0.0.1:8000/, you'll see something along the lines of:
Executing <Task finished name='Task-4' coro=<RequestResponseCycle.run_asgi() done, defined at /Users/mike.sukmanowsky/code/z/z/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py:401> result=None created at /Users/mike.sukmanowsky/code/z/z/.venv/lib/python3.13/site-packages/uvicorn/protocols/http/h11_impl.py:250> took 2.006 seconds
This is consistent with what uvloop and other event loop implementations do here.
But from this output I cannot determine:
- What endpoint this occurred on
- The full stack trace of my user-defined code that might point me to the culprit that's blocking the loop
For ASGI frameworks like FastAPI, blocking the event loop effectively means a death for concurrency.
I'm unaware of any way to make outputs more useful here, but I'm very much hoping either 1) I've missed an obvious way to do this or 2) this inspires some discussion that could lead to changes that'll eventually help all Python asyncio users better troubleshoot issues like this.
- Lingua principale
- Cython
- Stelle
- 11.9k
- Fork
- 615
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MagicStack/uvloop
-
License not clear Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
MagicStack/uvloop#759 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
MagicStack/uvloop#741 · 2 reazioni ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
MagicStack/uvloop#702 · 8 commenti · 9 reazioni ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
MagicStack/uvloop#766 ·
-
Directly constructed subprocess pipe protocols segfault when callbacks use a non-process owner Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
MagicStack/uvloop#765 ·
Tutte le issue di MagicStack/uvloop
Issue simili
-
bug customer-eng Durable Agents Inngest status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
-
integration: elevenlabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
home-assistant/core#182944 · 1 commento ·
-
ai-observability bug team/ai-observability
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
vicharanashala/fln#563 ·