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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-76327: freeze_support for non-Windows platforms #104607

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zetaloop
Copy link

@zetaloop zetaloop commented May 18, 2023

gh-76327: freeze_support for non-Windows platforms

This is a brief fix for the multiprocessing frozen executable infinite loop issue on non-Windows platform. #76327
And the freeze_support patch was exactly the same patch from PyInstaller, which already worked for them.

This patch does not influence PyInstaller.
However, this patch will enable cx_freeze or other similar tools to build multiprocessing apps for Linux and Mac.


馃摎 Documentation preview 馃摎: https://cpython-previews--104607.org.readthedocs.build/

@bedevere-bot
Copy link

Most changes to Python require a NEWS entry.

Please add it using the blurb_it web app or the blurb command-line tool.

@cpython-cla-bot
Copy link

cpython-cla-bot bot commented May 18, 2023

All commit authors signed the Contributor License Agreement.
CLA signed

@zetaloop
Copy link
Author

Backport needed.

@arhadthedev arhadthedev added the needs backport to 3.11 only security fixes label May 20, 2023
@zetaloop
Copy link
Author

Tests done.
Windows 11 (Python 3.11.1): PyInstaller鉁旓笍 cx_freeze鉁旓笍 py2exe鉁旓笍
WSL Ubuntu 22.04 (Python 3.10.6): PyInstaller鉁旓笍 cx_freeze鉁旓笍

Note: if we don't modify muliprocessing, cx_freeze on Linux will create an app with terrible infinite loop.

import multiprocessing

def worker():
    print('Worker')

if __name__ == '__main__':
    multiprocessing.freeze_support()
    multiprocessing.set_start_method('spawn')
    p = multiprocessing.Process(target=worker)
    p.start()

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

Successfully merging this pull request may close these issues.

None yet

4 participants