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

Simone Deponti shywolf9982 at gmail.com
Tue Jul 21 13:02:47 EDT 2009

On 07/21/2009 04:06 PM, Jean-Paul Calderone wrote:
> This is probably due to<http://twistedmatrix.com/trac/ticket/3851>.  It's
> not clear what the best solution is yet.

Hi all,

In the bug report I see:

 > after an unclean shutdown by a previous twistd, a new process is
 > started and is allocated the same pid as is in the pidfile which was
 > left behind. This process now causes twistd to think another twistd
 > process is still running in the directory.

If I understand well, the (rather unlucky, but not all that improbable) 
case we are talking about here is twisted getting reassigned the same 
PID that it was running with before?

1. Twisted is running with PID 401 and suffers an unclean shutdown.
2. Twisted is restarted and is reassigned the same PID (likely if it's a 
daemon launched during startup and a reboot has happened)
3. Twisted invokes checkPID (which reads from the stale pidfile) and 
sees that, after all, there is a process 401 running
4. Twisted claims another process is running

Why this can't be solved by comparing the pid in the file with 
os.getpid() (before throwing the error)?

More information about the Twisted-Python mailing list