[Twisted-Python] Incorrect "Another twistd server is running..."

Jean-Paul Calderone exarkun at divmod.com
Tue Jul 21 20:16:01 EDT 2009

On Wed, 22 Jul 2009 00:41:20 +0200, Simone Deponti <shywolf9982 at gmail.com> wrote:
>On 07/21/2009 07:10 PM, Christopher Armstrong wrote:
>>It's not necessarily a twistd process. It could be any process with
>>the same pid. checkPID only checks to see if the pid exists, not that
>>it's the PID of a twistd process.
>Disclaimer is, I might be extremely naive here. I have to admit I wasn't 
>able to figure out when checkPID is called (before or after a possible 
>daemonization? Since with how you have to write daemons in UNIX, doing a 
>os.getpid() _before_ daemonizing is not going to work the way I intend it 
>Anyway, what is currently done is: os.kill is invoked with signal 0, if we 
>get no OSError then sys.exit is invoked.
>What I propose is if no OSError is raised, we first check that os.getpid() 
>is different from the pid we read from the file, and if they are equal we 
>remove the stale file.
>Patch against r27172 attached.
>Don't shout at me if I haven't got it (it honestly seems way too easy: there 
>must be the trick ;))

This will fix the problem in one very unlikely case, but leave it broken in
the other somewhat more likely cases.  The problem is that some *other*
process may have been started on your system and given the PID from the
pidfile.  Your proposed change won't fix that case.


More information about the Twisted-Python mailing list