在Python(3.6(中,我试图在芹菜任务(芹菜3.1.17(中创建进程(具有多处理(,但它给出了错误:
守护进程不允许有子进程
代码
def mp():
with concurrent.futures.ProcessPoolExecutor(max_workers=90) as executor:
data = executor.map(pdfocr,[no for no in list(json.keys())])
用-P threads
参数启动工作程序:
celery worker -P threads
芹菜版本>=4.4.0已正式支持
参考:https://github.com/celery/celery/issues/4525#issuecomment-566503932
尝试使用billiard
包可以解决此问题。我在使用prefect
&dask
。
import billiard
from concurrent.futures import ProcessPoolExecutor
ProcessPoolExecutor(mp_context=billiard)