Eric Snow <ericsnowcurren...@gmail.com> added the comment:

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?

----------
nosy: +lukasz.langa

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39042>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to