Message282756
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. |
|
Date |
User |
Action |
Args |
2016-12-09 03:05:34 | sxsns243 | set | recipients:
+ sxsns243, vstinner, neologix, takluyver, minrk, Andre Merzky |
2016-12-09 03:05:34 | sxsns243 | set | messageid: <1481252734.23.0.513932902403.issue23395@psf.upfronthosting.co.za> |
2016-12-09 03:05:34 | sxsns243 | link | issue23395 messages |
2016-12-09 03:05:33 | sxsns243 | create | |
|