This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Multiprocessing infinite loop on Windows
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: multiprocessing can do equivalent of a fork bomb on Windows
View: 15646
Assigned To: Nosy List: amaury.forgeotdarc, ethan.furman, jnoller, sbt, tim.golden
Priority: normal Keywords:

Created on 2012-10-16 12:16 by ethan.furman, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg173033 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2012-10-16 12:16
On Windows multiprocessing has a well known limitation: because there is no fork() new shells must be invoked, and if the call that ultimately starts multiprocessing is not guarded by an `if __name__ == '__main___'` check an infinite loops results and you have a very nice brick instead of a computer.

On Stackoverflow I proposed a work-around [1], which is basically to check if an environment variable exists (MP_GUARD is this case), and if it does raise an exception.

I'm going to try and merge that into multiprocessing itself.  Are there any other platforms besides Windows where this is a problem?

[1] http://stackoverflow.com/q/12852643/208880
msg173040 - (view) Author: Tim Golden (tim.golden) * (Python committer) Date: 2012-10-16 13:07
The natural way to do this in windows is using the Job API:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms684161%28v=vs.85%29.aspx

However I'm not sure where to apply this within the multiprocessing
architecture (or if it's even a good idea).
msg173043 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2012-10-16 14:11
I think this is a duplicate of Issue #15646 which has been fixed in the 2.7 and 3.x branches.

If you run Lib/test/mp_fork_bomb.py you should get a RuntimeError with a helpful message telling you to use the 'if __name__ == "__main__"' idiom.
History
Date User Action Args
2022-04-11 14:57:37adminsetgithub: 60450
2013-02-14 17:57:35sbtsetstatus: pending -> closed
2012-10-16 14:11:04sbtsetstatus: open -> pending
superseder: multiprocessing can do equivalent of a fork bomb on Windows
messages: + msg173043

resolution: duplicate
stage: resolved
2012-10-16 13:07:01tim.goldensetnosy: + tim.golden
messages: + msg173040
2012-10-16 13:02:26r.david.murraysetnosy: + sbt

type: behavior
versions: + Python 3.4, - Python 3.1
2012-10-16 12:16:57ethan.furmancreate