You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a delibrate change, well you can call it a breaking change, but it's not a bug.
Nested profiler never (really) works in Python, the code you give is more like a "don't do this" example. It is equivalent (in Python 3.11) to
importcProfilep1=cProfile.Profile()
p1.enable()
p2=cProfile.Profile()
# p1 is silently disabled herep1.disable()
p2.enable()
That's not nested, that's just sequential profiling with two profilers - and if you really want to do that, you should be explicit!
A nested profiler should either
Be able to log what happens in the inner profiler from the outer profiler(which it can't)
Or at least for the outer profiler to continue to work after the inner profiler finishes(which it can't either)
Yes, the code given won't "report an error" in Python 3.11, but it also won't behave expectedly, it just keeps its mouth shut. I'd consider an error for "this is not how it's going to work!" as an improvement :)
manueljacob
changed the title
Nested profiling with cProfile stopped working in Python 3.12.
Nested profiling with cProfile raises exception in Python 3.12.
Oct 12, 2023
Bug report
Bug description:
In Python 3.11 this used to pass, but in Python 3.12 the last line raises “ValueError: Another profiling tool is already active”.
CPython versions tested on:
3.12
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: