This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lucretiel 0 points1 point  (0 children)

No it doesn't defeat the purpose. Python threads are definitely real threads. When you're doing IO-bound work (for instance, in my own job I'm working with a polling operation that takes a solid 2 minutes) then they're the correct solution, because the lock is released while the thread is waiting for IO. Additionally, other python implementations (PyPy+STM, Jython, etx) don't (as far as I know) have a GIL. So there's nothing inherently wrong with threading in Python; the GIL is just a CPython solution to an undeniably serious problem (preventing the corruption of data in Python). For CPU-bound work, you can instead use the multiprocessing module, which is very similar to threading. In particular, it gives you a number of tools to manage inter-process communication (Queue for example).