[New-bugs-announce] [issue5315] signal handler never gets called

Péter Szabó report at bugs.python.org
Thu Feb 19 14:47:08 CET 2009


New submission from Péter Szabó <ptspts at gmail.com>:

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.

----------
components: Interpreter Core, Library (Lib)
files: tsig.py
messages: 82472
nosy: pts
severity: normal
status: open
title: signal handler never gets called
type: behavior
versions: Python 2.4, Python 2.5
Added file: http://bugs.python.org/file13138/tsig.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5315>
_______________________________________


More information about the New-bugs-announce mailing list