[qmtest] [PATCH] Use processes instead of threads
Nathaniel Smith
njs at pobox.com
Sat May 1 08:49:03 UTC 2004
On Wed, Apr 28, 2004 at 11:36:21PM -0700, Zack Weinberg wrote:
> I am not particularly concerned about this either, but it does seem
> more abstractly correct to me to record the signal mask at startup
> (before creating any threads) and restore that after fork.
>
> I might be inclined to patch the Python core to do this, using
> pthread_atfork, except that wouldn't help us.
Amusingly, the signal module defines a function called
"PyOS_AfterFork", which appears to be responsible for resetting
various thread stuffs after a fork. It just doesn't touch signals at
all (which makes it location all the curiouser). I don't really
understand the Python source; PyOS_AfterFork is also defined in
Parser/intrcheck.c, somehow, with a somewhat different API.
In any case, this function should probably be doing signal mask stuff.
This still wouldn't fix the problem entirely, because popen(),
system() etc. don't trigger a call to PyOS_AfterFork (quoth
Doc/api/utilities.tex, "If a new executable is loaded into the new
process, this function does not need to be called"), so pthread_atfork
would perhaps be a better course.
Except, as you say, none of this would help us, not being able to
require users to use a fixed version of Python :-).
-- Nathaniel
--
"But suppose I am not willing to claim that. For in fact pianos
are heavy, and very few persons can carry a piano all by themselves."
More information about the qmtest
mailing list