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

Simone Deponti shywolf9982 at gmail.com
Tue Jul 21 18:41:20 EDT 2009

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 to).

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 ;))
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: twisted_samepid_r27172.patch
Url: http://twistedmatrix.com/pipermail/twisted-python/attachments/20090722/afb33559/attachment.txt 

More information about the Twisted-Python mailing list