是否有用于工作线程的Pool类,类似于多处理模块的Pool类?
我喜欢例如并行化地图功能的简单方法
def long_running_func(p):
    c_func_no_gil(p)
p = multiprocessing.Pool(4)
xs = p.map(long_running_func, range(100))
但是,我希望这样做而不会产生新流程的开销。
我知道GIL。但是,在我的用例中,该函数将是IO绑定的C函数,python包装程序将在实际函数调用之前为其释放GIL。
我必须编写自己的线程池吗?
                  这在Python Cookbook中看起来很有希望:Recipe 576519:具有与(multi)processing.Pool(Python)相同的API的线程池
                
                
                  
                    —
                    otherchirps 2010年
                    
                  
                
              
                  如今,它是内置的:
                
                  
                    —
                    martineau 
                    
                  
                
              from multiprocessing.pool import ThreadPool。
                
                  您能详细说明一下
                
                  
                    —
                    mrgloom 
                    
                  
                
              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.吗?
                
                  @mrgloom stackoverflow.com/questions/1294382
                
                
                  
                    —
                    Darklighter