Gracefully error out when there are concurrent profilers#692
Gracefully error out when there are concurrent profilers#69250-Course merged 1 commit intojazzband:masterfrom
Conversation
c8022e4 to
ac3f28d
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #692 +/- ##
==========================================
+ Coverage 86.65% 86.67% +0.02%
==========================================
Files 52 52
Lines 2113 2117 +4
==========================================
+ Hits 1831 1835 +4
Misses 282 282 ☔ View full report in Codecov by Sentry. |
f0b8b96 to
e4e8653
Compare
b42e593 to
6537b6e
Compare
|
I'd like to point out while this stop silk from interfering with processing a request, it also ends up not profiling that particular request. Prior to Python 3.11, the effect was similar but different (it would disable/stop the first profiler, and then start this current one). Neither outcome seems great, especially since this problem will happen when Django is processing multiple long-running requests at the same time (I've made a minimal repo here to highlight this issue) I think at a minimum, the documentation should tell users that this issue exists. In terms of a proper fix, I'm not sure at the moment if that's possible without using another profiler that properly supports multithreaded applications (such as https://github.com/sumerc/yappi) |
|
Thank you for pointing out this oversight, @robinchow. I'd take a look into yappi |
3.11 or 3.12? This code gives an error in python 3.12 but no error in 3.11: import cProfile
p1 = cProfile.Profile()
p1.enable()
p2 = cProfile.Profile()
p2.enable() |
|
@albertyw ah yes, apologies, prior to Python 3.12. |
Fixes #682
Unblocks #686