[Python-Dev] pthreads, fork, import, and execvp

"Martin v. Löwis" martin at v.loewis.de
Tue May 16 23:17:18 CEST 2006


Yair Chuchem wrote:
>     Rotem should simply avoid to fork() in the toplevel code of a module.
> 
> 
> this is not what happened.
> we called subprocess which itself called fork.

Ok - but are you calling subprocess in the context of code that is just
being imported? Or is the caller of the code that calls subprocess just
being imported? I.e. if you would trace back the stack at the point
of fork, would there be an import statement on any frame of the stack
(no matter how deeply nested)?

> as a subprocess bug this could be easily fixed by moving the import in
> "os._execve".
> we have made that fix locally and it fixes the problem.

I can readily believe that the problem went away. However, you did not
fix it - you worked around it. The import lock *ought* to be available
inside the execve code, so the import *ought* to work. By moving the
import outside execve, you have only hidden the problem, instead of
solving it.

Regards,
Martin


More information about the Python-Dev mailing list