Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executable file produces infinite count of processed with "multiprocessing" if "spawn" mode is selected. Ubuntu 18.04. #588

Closed
Yuriy-Leonov opened this issue Feb 15, 2020 · 3 comments · Fixed by #1956

Comments

@Yuriy-Leonov
Copy link

Hello.
I faced with following issue:

Env:

Ubuntu - 18.04
Python - 3.6.6
cx_Freeze - 6.1

Code base:

https://github.com/Yuriy-Leonov/cython_multiprocessing_issue

There is a simple main_script.py:

import multiprocessing


if __name__ == '__main__':
    print("step-1")
    multiprocessing.set_start_method("spawn")
    print("step-2")
    multiprocessing.freeze_support()
    print("step-3")
    manager = multiprocessing.Manager()
    print("step-4")
    s_dict = manager.dict()
    print("finish")

If run it with command python main_script.py expected things will happen - 5 print.

But If "make executable file" with following script and command python setup.py build:

import cx_Freeze

executables = [cx_Freeze.Executable("main_script.py")]

cx_Freeze.setup(
    name="Example",
    options={
        "build_exe": {
            "replace_paths": [("*", "")]
        },
    },
    executables=executables
)

and then run it from folder build/exe.linux-x86_64-3.6 like ./main_script it produces following log and infinite count of processes:

step-1
step-2
step-3
step-1
step-2
step-3
step-1
step-2
step-3
...

I'm not sure, did I do all in a right way, but it looks very unexpected from my sight. Therefore I've created this ticket.

@marcelotduarte
Copy link
Owner

The most important info from the code base:
###NOTE! Be careful, it could spawn infinite processes.
Prepare following command pkill -9 -f main_script and use it right after Ctrl + C on executable file

@marcelotduarte
Copy link
Owner

You can test the patch in the latest development build:
pip install --upgrade --pre --extra-index-url https://marcelotduarte.github.io/packages/ cx_Freeze

I tested the PR in Ubuntu 20.04 Python 3.10.6 but I expect that it should work from Python 3.8 to 3.12.

@marcelotduarte
Copy link
Owner

Release 6.15.4 is out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants