Multiprocessing Help. BrokenProcessPool Error

假如想象 提交于 2020-07-22 04:21:22

问题


I'm trying to learn the basics of multi-processing in python, and found the following example online which I wanted to practice with.

import concurrent.futures
import time

def do_something(seconds):    
    print(f' Sleeping {seconds} seconds')
    time.sleep(seconds)
    return f'Done Sleeping {seconds}'

with concurrent.futures.ProcessPoolExecutor() as executor:
    f1 = executor.submit(do_something, 1)
    print(f1.result())

Fairly simple, I know. However, for some reason when I try and run this, I get the following error.

Traceback (most recent call last):

File "", line 19, in print(f1.result())

File "C:\Anaconda3\lib\concurrent\futures_base.py", line 432, in result return self.__get_result()

File "C:\Anaconda3\lib\concurrent\futures_base.py", line 384, in __get_result raise self._exception

BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.

Any idea what is causing this?

来源:https://stackoverflow.com/questions/59581158/multiprocessing-help-brokenprocesspool-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!