【问题标题】:Pyinstaller exe on linux with dask cluster causes multiprocessing bomb带有 dask 集群的 Linux 上的 Pyinstaller exe 导致多处理炸弹
【发布时间】:2020-10-09 13:05:09
【问题描述】:

我正在使用 pyinstller 在 linux 中创建一个 python 可执行文件。该脚本使用带有 processes=True 参数的 Dask 本地集群。该脚本在终端中使用 python 命令执行时工作正常。但是在使用可执行文件运行时会导致多处理炸弹。

PS:我能够在 Windows 中使用 freeze_support() 在 Windows 中解决此问题,但在 Linux 中找不到解决方法。

注意:我使用的是 Python3.5.5 和 pyinstaller3.6

【问题讨论】:

    标签: python linux pyinstaller python-multiprocessing dask


    【解决方案1】:

    在 Python 中,您需要在 if __name__ == "__main__": 块中启动其他进程

    # myscript.py
    
    import dask.distributed
    
    ... custom code
    
    if __name__ == "__main__":
        client = dask.distributed.Client()  # spawns processes
    
        main()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-25
      • 2013-08-22
      • 1970-01-01
      • 2018-11-25
      • 2014-09-16
      • 2023-02-07
      • 1970-01-01
      相关资源
      最近更新 更多