问题
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