Thanks for the enlightenment. I'll try with commenting these lines and
report back if I notice anything weird going on.


-----Original Message-----
From: ext Murphy McCauley [] 
Sent: Friday, June 10, 2011 9:50 AM
Cc: Partti, Tapio (NSN - FI/Espoo)
Subject: Re: [nox-dev] Event triggered subprocess call

So the confusing bit is that you're being lied to.  The lambda function
referred to is actually on line 132 of coreapps/pyrt/

Inside, os.waitpid has been called and is blocking.  This
where the stack trace leads.  However, while waitpid is blocking, the
from the subprocess dying is causing the signal handler from to be invoked, which is causing an exception
because the 
handler (a lambda function) is taking no arguments by Python tries to
call it 
with two (I believe I am responsible for this bug -- oops!).  The
then throws an exception in the context of the call that was interrupted

instead of at the actual site (kind of understandable, but confusing for


So, to fix this, you can just fix the lambda function, by changing line
132 in to:
signal.signal(signal.SIGCHLD, lambda n,f: self.callLater(0,

However, since this code was originally written, I think Twisted has 
confronted handling of child process reaping, which is what lines 132
and 138 
in pyoxidereactor are trying to fix.  So... I think you can probably
comment out lines 132 and 138 and Twisted will take care of this.  I'm
Twisted expert, though.  If you notice that removing these lines leads
zombie processes, add them back in (and let me know, please!). :)

-- Murphy

On Thursday, June 09, 2011 02:37:47 AM Partti, Tapio (NSN - FI/Espoo)
> Hi all.
> When giving out a subprocess call (with subprocess.check_call) in any
> event's callback function, nox gives out the following error.
> 00003|reactor|ERR:Unhandled Error
>         Traceback (most recent call last):
>         --- <exception caught here> ---
>           File "./nox/coreapps/pyrt/", line 85, in
> __call__
>             self.func(*self.args, **;
>           File "./nox/coreapps/examples/", line 110, in
> timer_callback
>             subprocess.check_call('uname', shell=True)
>           File "/usr/lib/python2.6/", line 483, in
> check_call
>             retcode = call(*popenargs, **kwargs)
>           File "/usr/lib/python2.6/", line 470, in call
>             return Popen(*popenargs, **kwargs).wait()
>           File "/usr/lib/python2.6/", line 1182, in wait
>             pid, sts = _eintr_retry_call(os.waitpid,, 0)
>           File "/usr/lib/python2.6/", line 455, in
> _eintr_retry_call
>             return func(*args)
>         exceptions.TypeError: <lambda>() takes no arguments (2 given)
> In the sample case I put a line <subprocess.check_call('uname',
> shell=True)> in pyswitches timer_callback function. If I do the same
> some simple python application using twisted reactor, there are no
> errors. Could someone explain why the error occurs and what is the
> reason for it? I mean, I can ignore this error with a try-catch
> and everything seems ok, but am I then doing something that should not
> be done for some good reason.
> Thanks,
> Tapio Partti
nox-dev mailing list

Reply via email to