小编Ste*_*eph的帖子

Concurrent.futures > 在命令行中运行良好,而不是在使用 pyinstaller 或 py2exe 编译时

我有一个基于 concurrent.futures 的非常简单的脚本,它在命令行(Python 2.7)中运行良好,但是在使用 py2exe 或 Pyinstaller 编译时崩溃(编译后的程序会打开越来越多的进程,如果我不这样做,最终会完全阻塞窗口)先杀了他们)。

代码非常标准/简单,所以我很难理解这个问题的起源......有没有人更早经历过这个?(我发现与多处理的类似问题相关的讨论......但没有什么可以用来解决我的问题)

# -*- coding: utf8 -*-
import os
import socket
import concurrent.futures

def simple_checkDomain(aDomain):
    print aDomain 
    # Do other stuff

def main():

    with concurrent.futures.ProcessPoolExecutor(max_workers=4) as executor:
        for domain in ["google.com","yahoo.com"]:
            job = executor.submit(simple_checkDomain, domain)

if __name__ == "__main__":
    main()
Run Code Online (Sandbox Code Playgroud)

最好的问候,S

python py2exe pyinstaller multiprocessing concurrent.futures

4
推荐指数
2
解决办法
1232
查看次数