`asyncio.print_call_graph()` loses the call stack at asynchronous generators
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Bug report
Bug description:
asyncio.print_call_graph() stops at the first async gen in the await chain and silently drops all of the call stack below it
Repro:
import asyncio
async def deep():
await asyncio.Event().wait()
async def producer():
await deep()
yield 1
async def consumer():
async for _ in producer():
pass
async def main():
t = asyncio.create_task(consumer(), name='consumer')
await asyncio.sleep(0.05)
print(asyncio.format_call_graph(t))
asyncio.run(main())
Expected:
* Task(name='consumer', id=0x105be89b0)
+ Call stack:
| File '/Users/timofeiivankov/cpython/Lib/asyncio/locks.py', line 210, in async Event.wait()
| File '/Users/timofeiivankov/cpython/repro.py', line 4, in async deep()
| File '/Users/timofeiivankov/cpython/repro.py', line 7, in async generator producer()
| File '/Users/timofeiivankov/cpython/repro.py', line 11, in async consumer()
Actual:
* Task(name='consumer', id=0x105b089b0)
+ Call stack:
| File '/Users/timofeiivankov/cpython/repro.py', line 11, in async consumer()
Proposed fix: expose the wrapped generator as ag_gen and step over the wrapper through it
Have a fix ready for that
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-156984
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par asyncio.format_call_graph() et le reproducer de l’issue, notamment le générateur asynchrone producer() et la tâche consommatrice. Vérifiez comment le graphe d’appels parcourt la chaîne de await et comparez sa sortie avec la pile attendue. Le travail est terminé lorsque la sortie conserve les frames situées sous le générateur asynchrone ; le PR lié gh-156984 indique que le travail est déjà en cours.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- devtools
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 25/100