python3: signal.signal/singal.alarm

Alan alanwilter at gmail.com
Thu Jul 15 09:13:37 EDT 2010


Hi there,

I have this, say timeTol = 5 (5 seconds) and 'cmd' takes minutes to execute
:

            import subprocess as sub

            ...

            p = sub.Popen(cmd, shell=True, stderr = sub.STDOUT, stdout =
sub.PIPE)

            pid = p.pid

            signal.signal(signal.SIGALRM, signal_handler)

            signal.alarm(timeTol)

And it works on python 2.x.

However, on python 3.x, the signal_handler is only called when 'p =
sub.Popen...' has finished (after minutes) and signal.alarm appears to not
be called at 5 sec. Can someone please explain me this behaviour and how to
solve this?

Many thanks in advance,

Alan
-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100715/00d670b5/attachment.html>


More information about the Python-list mailing list