This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.snow
Recipients eric.snow, lukasz.langa
Date 2019-12-17.17:09:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1576602559.16.0.995481992445.issue39042@roundup.psfhosted.org>
In-reply-to
Content
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?
History
Date User Action Args
2019-12-17 17:09:19eric.snowsetrecipients: + eric.snow, lukasz.langa
2019-12-17 17:09:19eric.snowsetmessageid: <1576602559.16.0.995481992445.issue39042@roundup.psfhosted.org>
2019-12-17 17:09:19eric.snowlinkissue39042 messages
2019-12-17 17:09:18eric.snowcreate