[Python-ideas] An error in multiprocessing on MacOSX?
mwm at mired.org
Wed Nov 21 23:25:53 CET 2012
On Wed, Nov 21, 2012 at 2:57 PM, Gregory P. Smith <greg at krypto.org> wrote:
> On Wed, Nov 21, 2012 at 12:49 PM, Ronald Oussoren <ronaldoussoren at mac.com>
>> On 21 Nov, 2012, at 16:12, Sturla Molden <sturla at molden.no> wrote:
> well, it depends. its not right to ask for "non-posix code" as the
> restrictions of what you can use after a fork() are related to what you've
> done before the fork (as someone else stated). if your process has spawned
> threads, the entire python interpreter is unsafe to use after a fork()
If your process has spawned threads, POSIX fork() is unsafe. It
creates a clone of your process with every thread but the one calling
fork() stopped dead. Unless you can guarantee that this was a safe
thing to do then (i.e. - all your other threads hold no locks, have no
shared data structures in violation of invariant, etc.), you can be
hosed. Some cases can even hose the parent process.
Calling exec shortly after doing the fork will help with some of these
issues. Not all of them.
More information about the Python-ideas