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.

Author lars
Recipients lars
Date 2013-09-10.14:53:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1378824821.26.0.31883015251.issue18999@psf.upfronthosting.co.za>
In-reply-to
Content
The new multiprocessing based on forkserver (issue8713) looks great, but it has two problems. The first:

"set_start_method() should not be used more than once in the program."

The documentation does not explain what the effect of calling it twice would be. Judging from the documentation, it should be possible to do

start_method = get_start_method()
if start_method is None:
    set_start_method('forkserver')

but this code shows the second problem: it always succeeds with the (undocumented!) side-effect of setting the start method in get_start_method, to the system default, if it hasn't been set already.

I was just going to forge a patch for joblib (http://pythonhosted.org/joblib/) to set the start method to forkserver at import time. But in the current state of affairs, it would be impossible for the user to safely override the start method before importing joblib, because joblib can't figure out if it's been set already without setting it.

The enclosed patch solves the problem by making the new functions more robust:

* get_start_method no longer sets anything, but returns None if the start method has not been set already;
* set_start_method raises a RuntimeError (for want of a better exception type) when resetting the start method is attempted.

Unfortunately, I had to hack up the tests a bit, because they were violating the set_start_method contract. There is a test for the new set_start_method behavior, though, and all {fork,forkserver,spawn} tests pass on Linux.
History
Date User Action Args
2013-09-10 14:53:41larssetrecipients: + lars
2013-09-10 14:53:41larssetmessageid: <1378824821.26.0.31883015251.issue18999@psf.upfronthosting.co.za>
2013-09-10 14:53:41larslinkissue18999 messages
2013-09-10 14:53:40larscreate