multiprocessing module backport from 3 to 2.7 - spawn feature

Devin Jeanpierre jeanpierreda at gmail.com
Wed Jan 28 15:50:50 EST 2015


On Wed, Jan 28, 2015 at 10:06 AM, Skip Montanaro
<skip.montanaro at gmail.com> wrote:
> On Wed, Jan 28, 2015 at 7:07 AM, Andres Riancho <andres.riancho at gmail.com>
> wrote:
>> The feature I'm specially interested in is the ability to spawn
>> processes [1] instead of forking, which is not present in the 2.7
>> version of the module.
>
> Can you explain what you see as the difference between "spawn" and "fork" in
> this context? Are you using Windows perhaps? I don't know anything obviously
> different between the two terms on Unix systems.

On Unix, if you fork without exec*, and had threads open, threads
abruptly terminate, resulting in completely broken mutex state etc.,
which leads to deadlocks or worse if you try to acquire resources in
the forked child process. So in such circumstances, multiprocessing
(in 2.7) is not a viable option. But 3.x adds a feature, "spawn", that
lets you fork+exec instead of just forking.

I too would be interested in such a backport. I considered writing
one, but haven't had a strong enough need yet.

-- Devin



More information about the Python-list mailing list