[Twisted-Python] [PATCH] to make twisted more "child process friendly"
Hello,
Working on apt-proxy v2 I got stuck trying to get the status of a
subprocess:
internet/default.py:76
signal.signal(signal.SIGCHLD, process.reapProcess)
process.reapProcess will be called for every child that exists,
which makes imposible to anyone to get the status. And actually
makes useless calling 'reapProcess' from
Process.maybeCallProcessEnded
The patch allows objects to be registered to get the termination status
of certain processes and changes process.Process to use it.
I know that now the inline documentation gets outdated, I am willing to
update it if you guys like the patch.
Take care
ranty
--
--- Manuel Estrada Sainz
On Fri, Jun 21, 2002 at 04:18:35PM +0200, Manuel Estrada Sainz wrote:
Hello,
Working on apt-proxy v2 I got stuck trying to get the status of a subprocess:
internet/default.py:76 signal.signal(signal.SIGCHLD, process.reapProcess)
process.reapProcess will be called for every child that exists, which makes imposible to anyone to get the status. And actually makes useless calling 'reapProcess' from Process.maybeCallProcessEnded
The patch allows objects to be registered to get the termination status of certain processes and changes process.Process to use it.
That patch has a problem, if you use registerReapProccessHandler but
the process finished before you actually called
registerReapProccessHandler you will wait for ever on a dead child.
The attached patch makes two variations:
- reapProcess only takes the status of registered pid's, the rest are
left alone.
- registerReapProccessHandler checks if the child already exited and
if so directly calls the callback.
This also has the side efect of being more friendly to standard python
popen, which will again be able to return the status on close().
Thanks for a great job,
ranty
PS: Twisted rocks :)
--
--- Manuel Estrada Sainz
From: Manuel Estrada Sainz
That patch has a problem, if you use registerReapProccessHandler but the process finished before you actually called registerReapProccessHandler you will wait for ever on a dead child.
Yeah, stuff like that's the reason for the shotgun approach that was in place before.
The attached patch makes two variations:
Thanks for the update! I'll look at it closely and apply it soon.
PS: Twisted rocks :)
Indeed it does :-) -- | <`'> | Glyph Lefkowitz: Traveling Sorcerer | | < _/ > | Lead Developer, the Twisted project | | < ___/ > | http://www.twistedmatrix.com |
participants (2)
-
Glyph Lefkowitz
-
Manuel Estrada Sainz