asyncio eager tasks have no awaited_by edge during their first step
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Führen Sie die bereitgestellte asyncio-Reproduktion mit eager_task_factory aus und vergleichen Sie ihren Aufrufgraphen mit dem Standard-Task-Factory. Untersuchen Sie den im Bericht beschriebenen eager start und die Registrierung von awaited_by; fertig ist es, wenn der erste Kindschritt seinen Parent im Abschnitt “Awaited by” zeigt, ohne das bestehende Verhalten zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100