This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pts
Recipients pts
Date 2009-02-19.13:47:04
SpamBayes Score 9.917248e-06
Marked as misclassified No
Message-id <1235051228.14.0.0909837566577.issue5315@psf.upfronthosting.co.za>
In-reply-to
Content
According to http://docs.python.org/dev/library/signal.html , if I set
up a signal handler in the main thread, and then have the signal
delivered to the process, then the signal handler will be called in the
main thread. The attached Python script I've written, however, doesn't
work that way: sometimes the signal is completely lost, and the signal
handler is not called.

Here is how it should work. The code has two threads: the main thread
and the subthread. There is also a signal handler installed. The main
thread is running select.select(), waiting for a filehandle to become
readable. Then the subthread sends a signal to the process. The signal
handler writes a byte to the pipe. The select wakes up raising
'Interrupted system call' because of the signal.

I'm running Ubuntu Hardy on x86_64. With Python 2.4.5 and Python 2.5.2,
sometimes the signal handler is not called, and the select continues
waiting indefinitely. This is what I get on stdout in Python 2.4.5:

main pid=8555
--- 0
A
B
S
T
U
handler arg1=10 arg2=<frame object at 0x79ab40>
select got="(4, 'Interrupted system call')"
read str='W'
--- 1
A
B
S
T
U

This means that iteration 0 completed successfully: the signal handler
got called, and the select raised 'Interrupted system call'. However,
iteration 1 was stuck: the signal handler was never called, and the
select waits indefinitely.

The script seems to work in Python 2.4.3, but it hangs in iteration
about 60000.
History
Date User Action Args
2009-02-19 13:47:09ptssetrecipients: + pts
2009-02-19 13:47:08ptssetmessageid: <1235051228.14.0.0909837566577.issue5315@psf.upfronthosting.co.za>
2009-02-19 13:47:06ptslinkissue5315 messages
2009-02-19 13:47:05ptscreate