Open
Description
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