簡體   English   中英

python中的多處理[破池進程]

[英]Multiprocessing in python [broken pool process]

我是多處理的新手,正在探索如何使用它們。 當我參考python 文檔示例時,我只是嘗試了我的一個功能,但我的 jupyter notebook 給了我一個錯誤。 可能是什么原因?

import concurrent.futures

def dummy(x):
    return x**(1/200)

def main():
    with concurrent.futures.ProcessPoolExecutor() as executer:
        x =[1,2,3,4,5,6]
        future = executer.map(dummy,x)
        for result in future:
            print(result)
if __name__ == '__main__':
    main()

錯誤是:我將如何解決這個問題? 我有最新版本的 Python。


BrokenProcessPool:進程池中的一個進程在 future 正在運行或掛起時突然終止。

看起來就像我在使用 Jupyter 筆記本一樣,這是問題所在。 我剛剛從文檔中閱讀了這一行,“模塊必須可由工作子進程導入。這意味着 ProcessPoolExecutor 將無法在交互式解釋器中工作”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM