Profilers do not work in threads
オープン
まだ誰も着手していません。
docs
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
This issue is related to, but not the same as #110770.
Running two profilers in parallel threads raises an unexpected error.
It's not clear at all that the profiler will not work in parallel.
Either this is a bug or there should be a prominent warning in the docs.
import time
from cProfile import Profile
from threading import Thread
def task_sleep() -> None:
pr = Profile()
pr.enable()
time.sleep(1)
pr.disable()
t1 = Thread(target=task_sleep)
t2 = Thread(target=task_sleep)
t1.start()
t2.start()
t1.join()
t2.join()
Exception in thread Thread-2 (task_sleep):
ValueError: Another profiling tool is already active
CPython versions tested on:
3.12
Operating systems tested on:
Windows
Linked PRs
- gh-124671
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Python 3.12 で、提供された cProfile.Profile と threading の例を使って失敗を再現し、その後 profiler とスレッドの相互作用を調査します。リンクされた PR gh-124671 を確認し、受け入れられた結果が、ValueError なしで並列 profiler が動作することなのか、それともドキュメントに目立つ警告を追加することなのかを判断します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- performance
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100