Message282756
| Author |
sxsns243 |
| Recipients |
Andre Merzky, minrk, neologix, sxsns243, takluyver, vstinner |
| Date |
2016年12月09日.03:05:33 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1481252734.23.0.513932902403.issue23395@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Recently I've encountered the similar problem.
I found the case that SIGINT signal is ignored(set as SIG_IGN) due to the external reason.
If the python program starts background in bash script, bash set SIGINT as SIG_IGN.
test_interrupt.py
import _thread
_thread.interrupt_main()
run.sh
#!/bin/bash
python test_interrupt.py &
sleep 1s
./run.sh
Traceback (most recent call last):
File "test_interrupt.py", line 2, in <module>
_thread.interrupt_main()
RuntimeError: the SIGINT signal is ignored
(it was TypeError: 'int' object is not callable before the patch)
Python mapped default_int_handler to SIG_INT on SIG_DFL in PyInit__signal.
As the python developer can't control how the program is started, it may be better to setup default_int_handler regardless the handler type.
And initially SIG_INT is mapped to default_int_handler but once signal.signal is called, the mapping is lost even though the SIG_DFL is specified.
It may need to handle SIG_INT specially in signal_signal_impl as well to keep the consistent behavior. |
|