classification
Title: Multiprocessing freeze_support raises RuntimeError
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.4
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Michael.McAuliffe, davin, sbt
Priority: normal Keywords:

Created on 2014-08-23 00:38 by Michael.McAuliffe, last changed 2015-05-09 01:22 by davin. This issue is now closed.

Messages (3)
msg225719 - (view) Author: Michael McAuliffe (Michael.McAuliffe) Date: 2014-08-23 00:38
On Windows, I froze a script that uses multiprocessing with cx-freeze and Python 3.4.1 that had freeze_support() in the "if __name__ == '__main__'" section of the main module, and the resulting executable crashes with a RuntimeError 'context has already been set'.

The error happens in a call to set_start_method in multiprocessing.spawn's prepare function, and changing the line in spawn.py from:

if 'start_method' in data:
    set_start_method(data['start_method'])

to:

if 'start_method' in data:
    set_start_method(data['start_method'], force = True)

allows the frozen executable to successfully run.
msg237276 - (view) Author: Davin Potts (davin) * (Python committer) Date: 2015-03-05 17:01
Updates to both cx-freeze and multiprocessing in the meantime may likely have addressed this since this issue was first reported.  Granted, diagnosing issues with cx-freeze are best directed to the cx-freeze project -- that is perhaps where this issue should be opened instead.

Can this issue still be reproduced?  If so, a short example would be much appreciated.
msg242788 - (view) Author: Davin Potts (davin) * (Python committer) Date: 2015-05-09 01:22
The issue may already be addressed for the OP and without further information we don't know what or if anything needs pursuing.  If new information surfaces, a new issue should be opened.
History
Date User Action Args
2015-05-09 01:22:47davinsetstatus: pending -> closed
resolution: out of date
messages: + msg242788
2015-03-05 17:01:45davinsetstatus: open -> pending

nosy: + davin
messages: + msg237276

type: crash -> behavior
2014-08-23 16:38:13berker.peksagsetnosy: + sbt
2014-08-23 00:38:58Michael.McAuliffecreate