Message357390
I have an application (https://github.com/litxio/ptghci) using embedded Python, which needs to set a signal handler (and use the prompt-toolkit library which itself sets signal handlers).
My call to signal.signal is guarded by a check that we're running in the main thread:
if threading.current_thread() is threading.main_thread():
print (threading.current_thread().name)
signal.signal(signal.SIGINT, int_handler)
And the above indeed prints "MainThread". But this raises an exception:
File "app.py", line 45, in __init__
signal.signal(signal.SIGINT, int_handler)
File "/usr/lib/python3.8/signal.py", line 47, in signal
handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
This seems like something that should not happen.
Now, I tried to generate a simple replicating example but thus far haven't been able to do so -- simply calling signal.signal from PyRun_SimpleString doesn't do the trick, even within a pthreads thread. |
|
Date |
User |
Action |
Args |
2019-11-24 06:06:20 | Richard Warfield | set | recipients:
+ Richard Warfield |
2019-11-24 06:06:20 | Richard Warfield | set | messageid: <1574575580.88.0.320595380442.issue38904@roundup.psfhosted.org> |
2019-11-24 06:06:20 | Richard Warfield | link | issue38904 messages |
2019-11-24 06:06:20 | Richard Warfield | create | |
|