在启动多进程的文件头部执行如下代码即可:
import multiprocessing as mp try: mp.set_start_method('spawn', force=True) print("spawned") except RuntimeError: pass
参考:
multiprocessing - mp.set_start_method('spawn') triggered an error saying the context is already been set - Stack Overflow
Python多进程应用在Docker容器中卡住了?