I ran cprofile on a bit of code, which among other things spawns several threads that do most of the work. When I looked at the output of the profiling, I see no logging of all the functions that were called inside the threads. I am sure they were called, as they do stuff that is easy to see such as writing to a DB etc.
Does cProfile not profile threads? Am I missing something?
Found the answer here: link
It's worth pointing out that using the profiler only works (by default) on the main thread, and you won't get any information from other threads if you use them. This can be a bit of a gotcha as it is completely unmentioned in the profiler documentation. If you also want to profile threads, you'll want to look at the threading.setprofile() function in the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With