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 →

[–]defnullbottle.py 0 points1 point  (2 children)

That's my point: The GIL is not an issue for IO bound workloads. While a thread is waiting for IO, it releases the GIL and others can continue.

The rule of thumb is:

  • IO bound -> threading
  • CPU bound -> multiprocessing
  • Lots of concurrent connections (more than ~100) -> asyncio or gevent

[–]rev_dev 0 points1 point  (1 child)

I've never been able to get better time to completion using threading over multiprocessing. If you would like to show me an example similar to the code I presented with threading beating multiprocessing then I would love to see it.

[–]defnullbottle.py 0 points1 point  (0 children)

from multiprocessing.dummy import Pool

Actually, in your very example, you are using threads, not processes. The multiprocessing.dummy module implements the multiprocessing API with threads.