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

The --venv mode pex script does not have a __name__ == '__main__' guard breaking multiprocessing. #1236

Closed
jsirois opened this issue Feb 17, 2021 · 0 comments · Fixed by #1238
Assignees
Labels

Comments

@jsirois
Copy link
Member

jsirois commented Feb 17, 2021

The multiprocessing module relies on being able to import the file run as __main__ from spawned subprocesses without the side-effect of actually running __main__ code. See "Safe importing of main module" here: https://docs.python.org/3/library/multiprocessing.html#the-spawn-and-forkserver-start-methods

To play well with multiprocessing, the pex script should get a __main__ guard.

This was spotted over in #1235.

@jsirois jsirois added the bug label Feb 17, 2021
@jsirois jsirois self-assigned this Feb 17, 2021
jsirois added a commit to jsirois/pex that referenced this issue Feb 17, 2021
Add a test that passes for multiprocessing fork mode but fails for both
spawn and forkserver modes and fix the pex script to gaurd against non
`__name__ == '__main__'` mode to fix.

Fixes pex-tool#1236
jsirois added a commit that referenced this issue Feb 17, 2021
Add a test that passes for multiprocessing fork mode but fails for both
spawn and forkserver modes and fix the pex script to gaurd against non
`__name__ == '__main__'` mode to fix.

Fixes #1236
@jsirois jsirois changed the title The --venv mode pex script does not have a __name__ == '__main__' gaurd breaking multiprocessing. The --venv mode pex script does not have a __name__ == '__main__' guard breaking multiprocessing. Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant