René's URL Explorer Experiment


Title: bpo-32146: multiprocessing freeze_support needed outside win32 by bbayles · Pull Request #5195 · python/cpython · GitHub

Open Graph Title: bpo-32146: multiprocessing freeze_support needed outside win32 by bbayles · Pull Request #5195 · python/cpython

X Title: bpo-32146: multiprocessing freeze_support needed outside win32 by bbayles · Pull Request #5195 · python/cpython

Description: This PR un-breaks "frozen" executables (e.g., those produced by PyInstaller or cx_Freeze that (a) run on Unix, and (b) use multiprocessing, and (c) use the spawn or forkserver start methods. I linked to this dissection of the problem in the issue; it is a good overview of what goes wrong currently. In a nutshell, the forkserver and semaphore_tracker modules try to launch new processes with command line arguments that the "frozen" executable doesn't support: When using argparse, the error is clear: error: unrecognized arguments: -S -E -c from multiprocessing.semaphore_tracker import main;main(5) error: unrecognized arguments: -S -E -c from multiprocessing.forkserver import main; main(8, 9, ['__main__'], **{'sys_path': [''/opt/freeze_support_test/lib/library.zip', '/opt/freeze_support_test/lib']}) On Windows this problem is avoided because freeze_support captures the arguments, parses them, executes the appropriate code, and then exits here. It recognizes this by way of a dummy command line argument, --multiprocessing-fork. This PR: Removes the win32 check that prevents freeze_support from having an effect on Unix Adds dummy --multiprocessing-forkserver and --multiprocessing-semaphore-tracker command line arguments, which are only used with "frozen" executables Extends freeze_support such that it captures and parses the command line arguments for the fork server and semaphore tracker, and launches them. This fixes the problem for me on both PyInstaller and cx_Freeze on Unix. I couldn't find that there were any tests for the existing freeze_support code. I added some basic ones for the command line manipulation that I've added here, but it may be useful to file an issue to add others. I will add a few more comments in-line. I'm a new-ish contributor, so if discussion of the approach to fixing this issue should take place elsewhere (in the bug tracker or on a mailing list), please let me know (gently). Many thanks! https://bugs.python.org/issue32146

Open Graph Description: This PR un-breaks "frozen" executables (e.g., those produced by PyInstaller or cx_Freeze that (a) run on Unix, and (b) use multiprocessing, and (c) use the spawn or forkserver start metho...

X Description: This PR un-breaks "frozen" executables (e.g., those produced by PyInstaller or cx_Freeze that (a) run on Unix, and (b) use multiprocessing, and (c) use the spawn or forkserver sta...

Opengraph URL: https://github.com/python/cpython/pull/5195

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:8e02a921-1904-6a29-3dbc-a1224f149078
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idA11A:C4B79:832888:B675AB:6A4C96CE
html-safe-noncea06fd43027631a64c906dffff0a813dfd67bd07382669a49442c922d4c903801
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMTFBOkM0Qjc5OjgzMjg4ODpCNjc1QUI6NkE0Qzk2Q0UiLCJ2aXNpdG9yX2lkIjoiNjcxNTYyNjc1Mjg5MzAzMjE0MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac85e032db00a9f36b7deeefefed3d4275a34c15839121522430e892f25e964468
hovercard-subject-tagpull_request:163028603
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/5195/files
twitter:imagehttps://avatars.githubusercontent.com/u/1922815?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/1922815?s=400&v=4
og:image:altThis PR un-breaks "frozen" executables (e.g., those produced by PyInstaller or cx_Freeze that (a) run on Unix, and (b) use multiprocessing, and (c) use the spawn or forkserver start metho...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7a2dede45637df6b92ddcfe2a557e67d4b5854ae
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/5195/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F5195%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F5195%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/5195/files
Reloadhttps://github.com/python/cpython/pull/5195/files
Reloadhttps://github.com/python/cpython/pull/5195/files
Please reload this pagehttps://github.com/python/cpython/pull/5195/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/5195/files
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.8k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.6k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
bbayleshttps://github.com/bbayles
python:masterhttps://github.com/python/cpython/tree/master
bbayles:unix-freezesupport-3.7https://github.com/bbayles/cpython/tree/unix-freezesupport-3.7
Conversation 8 https://github.com/python/cpython/pull/5195
Commits 15 https://github.com/python/cpython/pull/5195/commits
Checks 0 https://github.com/python/cpython/pull/5195/checks
Files changed https://github.com/python/cpython/pull/5195/files
Please reload this pagehttps://github.com/python/cpython/pull/5195/files
bpo-32146: multiprocessing freeze_support needed outside win32 https://github.com/python/cpython/pull/5195/files#top
Show all changes 15 commits https://github.com/python/cpython/pull/5195/files
7b90728 bpo-32146: freeze_support can apply to non-Windows platforms also bbayles Jan 11, 2018 https://github.com/python/cpython/pull/5195/commits/7b907281ea1a90391e52b391f336fac33fd042cf
b0d30bc bpo-32146: Provisional fix for non-Windows executables (spawn) bbayles Jan 13, 2018 https://github.com/python/cpython/pull/5195/commits/b0d30bc48c1447356031742b44d95eaa1db17af3
8baf4e4 bpo-32146: Provisional fix for non-Windows executables (forkserver) bbayles Jan 14, 2018 https://github.com/python/cpython/pull/5195/commits/8baf4e4fc686c8e35d4e702bb78812453fe35077
64456d9 bpo-32146: Move commandline checks to separate functions bbayles Jan 14, 2018 https://github.com/python/cpython/pull/5195/commits/64456d9f7be5b0824bea9d7f36fe359042c733ac
748c2f1 bpo-32146: Add Misc/NEWS entry for freeze_support enhancements bbayles Jan 14, 2018 https://github.com/python/cpython/pull/5195/commits/748c2f1cc56c235b2ac0ee68286b87a3aa5abd9d
3a0964a bpo-32146: Use dummy --multiprocessing- command line arguments bbayles Jan 14, 2018 https://github.com/python/cpython/pull/5195/commits/3a0964ae759f181371d4520e0984cda71beea05c
7b49c00 bpo-32146: Only use special command line arguments when frozen bbayles Jan 15, 2018 https://github.com/python/cpython/pull/5195/commits/7b49c0078945df9bc492c61792e5c7a97c42e7c3
26a6313 bpo-32146: Factor out command line manipulation for testing bbayles Jan 15, 2018 https://github.com/python/cpython/pull/5195/commits/26a63138cd40d5d447f57fdadbf4927b532f0e12
afdd553 bpo-32146: Add note to docs about freeze_support on Unix bbayles Jan 15, 2018 https://github.com/python/cpython/pull/5195/commits/afdd5535fb92e19d3a77a8c6bc475b695aa0d4b2
d72742d bpo-32146: Add missing backtick bbayles Jan 15, 2018 https://github.com/python/cpython/pull/5195/commits/d72742dea5d50032eaf636193e5956cd07873d82
97e6a9d bpo-32146: Fix and add test for extra preload modules bbayles Jan 16, 2018 https://github.com/python/cpython/pull/5195/commits/97e6a9d748902353cfb4e730c471ff05810ca160
f0ca86b bpo-32146: Fix up comments bbayles Jan 29, 2018 https://github.com/python/cpython/pull/5195/commits/f0ca86b5fb59d3cd84dd2f612103823c90f12fca
fce2afc Merge branch 'master' into unix-freezesupport-3.7 bbayles Jul 13, 2018 https://github.com/python/cpython/pull/5195/commits/fce2afccfdb1146759014723483641f1379cb8ac
5a8e3c8 Merge remote-tracking branch 'upstream/master' into unix-freezesuppor… bbayles Jul 15, 2018 https://github.com/python/cpython/pull/5195/commits/5a8e3c8b866e9aba62b41341933ea1e7e291f8eb
23e9c64 Merge branch 'master' into unix-freezesupport-3.7 bbayles Jan 11, 2019 https://github.com/python/cpython/pull/5195/commits/23e9c64d6570a558fe99c417d28c7413af1522ee
Clear filters https://github.com/python/cpython/pull/5195/files
Please reload this pagehttps://github.com/python/cpython/pull/5195/files
Please reload this pagehttps://github.com/python/cpython/pull/5195/files
multiprocessing.rst https://github.com/python/cpython/pull/5195/files#diff-2cf07acf4f2d547e93e35c6a4ba2ee818e991b54e88da4a904ee0a49acb99eb3
context.py https://github.com/python/cpython/pull/5195/files#diff-68368c7bc63449f34e9b6e6f13715852f23061c0bf6497b1a9691c0860943f49
forkserver.py https://github.com/python/cpython/pull/5195/files#diff-8d5185659419cdf73e93f59cf3941dfe1c523d9e1310e349b4d4afe3b63cb66d
semaphore_tracker.py https://github.com/python/cpython/pull/5195/files#diff-86209dc00f04cec9a8a9628a37b8d279cbed67f3f61dc142da6a6c7c7d74e729
spawn.py https://github.com/python/cpython/pull/5195/files#diff-3612bea8104783e1f08635ddc3244cdde48e5b3b1339d4357abe5b78807834bc
_test_multiprocessing.py https://github.com/python/cpython/pull/5195/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
2018-01-14-16-34-26.bpo-32146.6pFDbn.rst https://github.com/python/cpython/pull/5195/files#diff-c36104af8ba57bb106f044d1b6c3497b69f6de7ba544268521e7274696ea422e
Doc/library/multiprocessing.rsthttps://github.com/python/cpython/pull/5195/files#diff-2cf07acf4f2d547e93e35c6a4ba2ee818e991b54e88da4a904ee0a49acb99eb3
View file https://github.com/bbayles/cpython/blob/23e9c64d6570a558fe99c417d28c7413af1522ee/Doc/library/multiprocessing.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5195/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5195/files#diff-2cf07acf4f2d547e93e35c6a4ba2ee818e991b54e88da4a904ee0a49acb99eb3
https://github.com/python/cpython/pull/5195/files#diff-2cf07acf4f2d547e93e35c6a4ba2ee818e991b54e88da4a904ee0a49acb99eb3
https://github.com/python/cpython/pull/5195/files#diff-2cf07acf4f2d547e93e35c6a4ba2ee818e991b54e88da4a904ee0a49acb99eb3
Lib/multiprocessing/context.pyhttps://github.com/python/cpython/pull/5195/files#diff-68368c7bc63449f34e9b6e6f13715852f23061c0bf6497b1a9691c0860943f49
View file https://github.com/bbayles/cpython/blob/23e9c64d6570a558fe99c417d28c7413af1522ee/Lib/multiprocessing/context.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5195/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5195/files#diff-68368c7bc63449f34e9b6e6f13715852f23061c0bf6497b1a9691c0860943f49
https://github.com/python/cpython/pull/5195/files#diff-68368c7bc63449f34e9b6e6f13715852f23061c0bf6497b1a9691c0860943f49
Lib/multiprocessing/forkserver.pyhttps://github.com/python/cpython/pull/5195/files#diff-8d5185659419cdf73e93f59cf3941dfe1c523d9e1310e349b4d4afe3b63cb66d
View file https://github.com/bbayles/cpython/blob/23e9c64d6570a558fe99c417d28c7413af1522ee/Lib/multiprocessing/forkserver.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5195/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5195/files#diff-8d5185659419cdf73e93f59cf3941dfe1c523d9e1310e349b4d4afe3b63cb66d
https://github.com/python/cpython/pull/5195/files#diff-8d5185659419cdf73e93f59cf3941dfe1c523d9e1310e349b4d4afe3b63cb66d
Lib/multiprocessing/semaphore_tracker.pyhttps://github.com/python/cpython/pull/5195/files#diff-86209dc00f04cec9a8a9628a37b8d279cbed67f3f61dc142da6a6c7c7d74e729
View file https://github.com/bbayles/cpython/blob/23e9c64d6570a558fe99c417d28c7413af1522ee/Lib/multiprocessing/semaphore_tracker.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5195/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5195/files#diff-86209dc00f04cec9a8a9628a37b8d279cbed67f3f61dc142da6a6c7c7d74e729
https://github.com/python/cpython/pull/5195/files#diff-86209dc00f04cec9a8a9628a37b8d279cbed67f3f61dc142da6a6c7c7d74e729
Lib/multiprocessing/spawn.pyhttps://github.com/python/cpython/pull/5195/files#diff-3612bea8104783e1f08635ddc3244cdde48e5b3b1339d4357abe5b78807834bc
View file https://github.com/bbayles/cpython/blob/23e9c64d6570a558fe99c417d28c7413af1522ee/Lib/multiprocessing/spawn.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5195/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5195/files#diff-3612bea8104783e1f08635ddc3244cdde48e5b3b1339d4357abe5b78807834bc
https://github.com/python/cpython/pull/5195/files#diff-3612bea8104783e1f08635ddc3244cdde48e5b3b1339d4357abe5b78807834bc
https://github.com/python/cpython/pull/5195/files#diff-3612bea8104783e1f08635ddc3244cdde48e5b3b1339d4357abe5b78807834bc
https://github.com/python/cpython/pull/5195/files#diff-3612bea8104783e1f08635ddc3244cdde48e5b3b1339d4357abe5b78807834bc
bbayleshttps://github.com/bbayles
Jan 15, 2018https://github.com/python/cpython/pull/5195/files#r161603852
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
semaphore_tracker.SemaphoreTracker.ensure_runninghttps://github.com/python/cpython/blob/cb064fc2321ce8673fe365e9ef60445a27657f54/Lib/multiprocessing/semaphore_tracker.py#L63-L70
semaphore_tracker.mainhttps://github.com/python/cpython/blob/cb064fc2321ce8673fe365e9ef60445a27657f54/Lib/multiprocessing/semaphore_tracker.py#L108
Please reload this pagehttps://github.com/python/cpython/pull/5195/files
https://github.com/python/cpython/pull/5195/files#diff-3612bea8104783e1f08635ddc3244cdde48e5b3b1339d4357abe5b78807834bc
Lib/test/_test_multiprocessing.pyhttps://github.com/python/cpython/pull/5195/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
View file https://github.com/bbayles/cpython/blob/23e9c64d6570a558fe99c417d28c7413af1522ee/Lib/test/_test_multiprocessing.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5195/{{ revealButtonHref }}
https://github.com/python/cpython/pull/5195/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/5195/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/5195/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
https://github.com/python/cpython/pull/5195/files#diff-c3db62f7c1928499afd71830c22c8bb8f56843a4533cecf69137973d73c489fc
Misc/NEWS.d/next/Library/2018-01-14-16-34-26.bpo-32146.6pFDbn.rsthttps://github.com/python/cpython/pull/5195/files#diff-c36104af8ba57bb106f044d1b6c3497b69f6de7ba544268521e7274696ea422e
View file https://github.com/bbayles/cpython/blob/23e9c64d6570a558fe99c417d28c7413af1522ee/Misc/NEWS.d/next/Library/2018-01-14-16-34-26.bpo-32146.6pFDbn.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/5195/{{ revealButtonHref }}
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.