asyncio eager tasks have no awaited_by edge during their first step
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
Task that created by eager task factory runs its first step before the awaited_by edge is registered. During this step the graph shows that this task is awaited by nobody
Repro:
import asyncio
async def child():
asyncio.print_call_graph()
await asyncio.sleep(0)
async def main():
await asyncio.gather(child())
loop = asyncio.new_event_loop()
loop.set_task_factory(asyncio.eager_task_factory)
loop.run_until_complete(main())
Expected:
* Task(name='Task-2', id=0x103544b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/repro.py', line 4, in async child()
+ Awaited by:
* Task(name='Task-1', id=0x103544d70)
+ Call stack:
| File '/Users/timofeiivankov/cpython/repro.py', line 8, in async main()
Actually:
* Task(name='Task-2', id=0x103058b90)
+ Call stack:
| File '/Users/timofeiivankov/cpython/repro.py', line 4, in async child()
With the default task factory it works fine as expected
Proposed fix: Register the edge inside the eager start and discard it when the step ends
I have a fix ready
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-157300
Guida per i contributori
Apri la guida per i contributori
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.
Direzione di ricerca
Esegui la riproduzione asyncio fornita con eager_task_factory e confronta il relativo grafo delle chiamate con quello della factory di task predefinita. Esamina l’eager start e la registrazione di awaited_by descritti nel report; il lavoro è completato quando il primo passaggio figlio mostra il proprio parent nella sezione “Awaited by” senza compromettere il comportamento esistente.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 25/100