Issue 16246: Multiprocessing infinite loop on Windows (original) (raw)

Issue16246

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:37 admin set github: 60450
2013-02-14 17:57:35 sbt set status: pending -> closed
2012-10-16 14:11:04 sbt set status: open -> pendingsuperseder: multiprocessing can do equivalent of a fork bomb on Windowsmessages: + resolution: duplicatestage: resolved
2012-10-16 13:07:01 tim.golden set nosy: + tim.goldenmessages: +
2012-10-16 13:02:26 r.david.murray set nosy: + sbttype: behaviorversions: + Python 3.4, - Python 3.1
2012-10-16 12:16:57 ethan.furman create