Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there such a thing as working threading in python?

I wrote a beautiful multithreaded script, and when I ran it, it performed worse with 25 threads than with just direct invocation of the thread handler.

Then I discovered the global interpreter lock. I want to ask, before I discard python for this script and rewrite the thing in something else, is there any way to do actual working multithreading in python?

like image 995
alexgolec Avatar asked Sep 04 '26 03:09

alexgolec


1 Answers

The other approach is to abandon threads and instead use the Multiprocessing module (Python 2.6+), which gets around the GIL, and has an API that's at least similar to the one in the threading module.

like image 120
bgporter Avatar answered Sep 05 '26 17:09

bgporter



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!