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

Christopher Armstrong radix at twistedmatrix.com
Tue Jul 21 13:10:30 EDT 2009

On Tue, Jul 21, 2009 at 1:02 PM, Simone Deponti<shywolf9982 at gmail.com> wrote:
> 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?

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.

> Example:
> 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)?

I don't think I understand this proposal.

Christopher Armstrong

More information about the Twisted-Python mailing list