`asyncio.print_call_graph()` loses the call stack at asynchronous generators
まだ誰も着手していません。
評価
調査の方向性
asyncio.format_call_graph() と issue の reproducer から始め、非同期ジェネレーター producer() と consumer task を含めます。コールグラフが await チェーンをどのようにたどるかを確認し、その出力を期待されるスタックと比較します。出力が非同期ジェネレーターより下のフレームを保持すれば完了です。リンクされている PR gh-156984 は、すでに作業が進行中であることを示しています。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 558
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
docs pending
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
build type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
stdlib topic-email type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
🐛 Bug 🔔 Pending processing
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
jumpserver/jumpserver#17584 ·