简体   繁体   English

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

[英]Concurrent.futures > works well in command line, not when compiled with pyinstaller or py2exe

I have a very simple script based on concurrent.futures that works well in command line (Python 2.7), but crashes when compiled with py2exe or Pyinstaller (the compiled program opens an increasing number of processes and eventually completely blocks windows if I don't kill them all first). 我有一个基于current.futures的非常简单的脚本,该脚本在命令行(Python 2.7)上运行良好,但是在使用py2exe或Pyinstaller进行编译时会崩溃(如果我不这样做,编译后的程序会打开越来越多的进程,并最终完全阻塞窗口首先杀死他们)。

The code is very standard/simple so I struggle to understand the origin of this issue... Has anyone experienced this earlier? 该代码非常标准/简单,因此我很难理解此问题的起因...有人早些经历过吗? (I found discussions related to a similar issue with multiprocessing... but nothing that I could use to solve my problem) (我发现与多处理中类似问题有关的讨论……但我无法解决任何问题)

# -*- 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()

Best regards, S 最好的问候,S

I was having this issue with cx_freeze in Python 3.4. 我在Python 3.4中遇到了cx_freeze的问题。 After a bit more google searches I landed on this bug report: http://bugs.python.org/issue21505 在经过更多的Google搜索之后,我找到了此错误报告: http : //bugs.python.org/issue21505

That sent me to the following docs and in my app, it seemed to fix the issue. 这使我进入了以下文档,并且在我的应用中,似乎可以解决该问题。

The suggested solution for Python 2.7, straight from the docs: multiprocessing.freeze_support 直接从文档获得的针对Python 2.7的建议解决方案: multiprocessing.freeze_support

Not sure if this will fix it for the py2exe or Pyinstaller that you are using but figured I would post in case. 不知道这是否能解决您正在使用的py2exe或Pyinstaller,但认为我会以防万一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM