Message358557
Hmm, I wonder if this should be considered a regression in 3.8. As demonstrated in issue38904, the following code changed behavior as of 3.8, under certain conditions:
import signal
import threading
def int_handler():
...
if threading.current_thread() == threading.main_thread():
signal.signal(signal.SIGINT, int_handler)
Note the specific conditions:
* threading and signal have not been imported yet
* the current thread when the module is *imported* is not the main thread (this only affects folks embedding Python)
Also note that the only other help we offer is a "private" function in the C-API: _PyOS_IsMainThread(). That would have given the correct answer, but we do not expect users to call it, and it doesn't help them from Python code anyway.
Also, the same problem existed pre-3.8 if signal and threading were imported in different threads before the above script ran.
Finally, I'm (mostly) confident that this would be a backward-compatible fix.
What do you think about this being a 3.8 regression, Łukasz? |
|
Date |
User |
Action |
Args |
2019-12-17 17:09:19 | eric.snow | set | recipients:
+ eric.snow, lukasz.langa |
2019-12-17 17:09:19 | eric.snow | set | messageid: <1576602559.16.0.995481992445.issue39042@roundup.psfhosted.org> |
2019-12-17 17:09:19 | eric.snow | link | issue39042 messages |
2019-12-17 17:09:18 | eric.snow | create | |
|