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

-Tapio

-----Original Message-----
From: ext Murphy McCauley [mailto:jam...@nau.edu] 
Sent: Friday, June 10, 2011 9:50 AM
To: nox-dev@noxrepo.org
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
being 
referred to is actually on line 132 of coreapps/pyrt/pyoxidereactor.py.

Inside subprocess.py, os.waitpid has been called and is blocking.  This
is 
where the stack trace leads.  However, while waitpid is blocking, the
SIGCHLD 
from the subprocess dying is causing the signal handler from 
pyoxidereactor.py:132 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
interpreter 
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

sure!).

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

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
just 
comment out lines 132 and 138 and Twisted will take care of this.  I'm
no 
Twisted expert, though.  If you notice that removing these lines leads
to 
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)
wrote:
> 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/pyoxidereactor.py", line 85, in
> __call__
>             self.func(*self.args, **self.kw);
>           File "./nox/coreapps/examples/pyswitch.py", line 110, in
> timer_callback
>             subprocess.check_call('uname', shell=True)
>           File "/usr/lib/python2.6/subprocess.py", line 483, in
> check_call
>             retcode = call(*popenargs, **kwargs)
>           File "/usr/lib/python2.6/subprocess.py", line 470, in call
>             return Popen(*popenargs, **kwargs).wait()
>           File "/usr/lib/python2.6/subprocess.py", line 1182, in wait
>             pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
>           File "/usr/lib/python2.6/subprocess.py", 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
in
> 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
sentence
> 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
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev

Reply via email to