[Twisted-Python] spawnProcess - reapProcess not retrying on failures

Justin Mazzola Paluska jmp at editshare.com
Tue Sep 2 07:38:55 MDT 2014


On 09/02/2014 09:31 AM, Adi Roiban wrote:
> Problem solved... see below
>
> On 2 September 2014 12:05, Justin Mazzola Paluska <jmp at editshare.com> wrote:
>> On 09/02/2014 05:08 AM, Adi Roiban wrote:
> [snip]
>
>>          if pid:
>>              self.processEnded(status)
>>              unregisterReapProcessHandler(pid, self)
>>          elif pid == 0:
>>              # Twisted seems to get stuck if pid is 0, which means that
>>              # the child process hasn't changed status, but if called
>>              # after SIGCHLD probably means that the child process is
>>              # in the process of dying, but hasn't quite died yet.
>>              # We'll try to kick the reactor to reap the processes
>>              # again in a bit.
>>              #
>>              # We're testing specifically against 0 because pid may
>>              # also be None in an error case.
>>              def unstick():
>>                  reapAllProcesses()
>>              reactor.callLater(1, unstick)
>>
>>      _BaseProcess.reapProcess = reapProcess
>>
>> ----
>>
>> To use this, import your reactor and then call
>> workaround_reapProcess(reactor).
>>
>> Now that two of us have seen the same problem, we should probably file a
>> ticket in the bug tracker.
>>      --Justin
> My quick fix was to only call reactor.callLater(self.reapProcess) and
> not to reap all processes

Fair enough.

FWIW, looking at your original code, you may also want to call your Deferreds in 
a reactor.callLater.  I learned the hard way that if you callback a Deferred 
from processEnded and the callback spawns another process, your process will 
still be Twisted's process table even though it's dying.

>
> ----------
>
> I dig deeper and I found out that since I was using
> reactor.run(installSignalHandlers=False)  _SIGCHLDWaker was not
> installed.
>
> I have switched to using just reactor.run() and the process is now killed.

Without my workaround, I continue to have the problem with the gtk2reactor.
     --Justin




More information about the Twisted-Python mailing list