I'm developing an inherently multithreaded module in Python, and I'd like to find out where it's spending its time. cProfile only seems to profile the main thread. Is there any way of profiling all threads involved in the calculation?
Multithreading in Python You can create threads by passing a function to the Thread() constructor or by inheriting the Thread class and overriding the run() method.
To implement threading in Python, you have to perform three steps: Inherit the class that contains the function you want to run in a separate thread by using the Thread class. Name the function you want to execute in a thread run() . Call the start() function from the object of the class containing the run() method.
Python doesn't allow multi-threading ,but if you want to run your program speed that needs to wait for something like IO then it use a lot.
Generally, Python only uses one thread to execute the set of written statements. This means that in python only one thread will be executed at a time.
Please see yappi (Yet Another Python Profiler).
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