Python thread pool similar to the multiprocessing Pool?

Posted by Martin on Stack Overflow See other posts from Stack Overflow or by Martin
Published on 2010-06-13T21:17:16Z Indexed on 2010/06/13 21:22 UTC
Read the original article Hit count: 391

Is there a Pool class for worker threads, similar to the multiprocessing module's Pool class?

I like for example the easy way to parallelize a map function

def long_running_func(p):
    c_func_no_gil(p)

p = multiprocessing.Pool(4)
xs = p.map(long_running_func, range(100))

however I would like to do it without the overhead of creating new processes.

I know about the GIL. However, in my usecase, the function will be an IO-bound C function for which the python wrapper will release the GIL before the actual function call.

Do I have to write my own threading pool?

© Stack Overflow or respective owner

Related posts about python

Related posts about multithreading