New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
signal.signal
may throw when on threading.main_thread
#91880
Comments
There's a mistake in this patch that I believe undoes at least part of the intent of the patch. When the exception is caught, the code sets:
but
so as to prevent the attempt to check the currently set SIGINT handler later (and potentially restore the default handler). As is, it leaves |
Thanks, I've opened a PR to correct my error. |
Ow, I should have caught that in review. |
#91880 (comment) - With thanks to @MojoVampire for spotting this. Automerge-Triggered-By: GH:gvanrossum
davidhewitt commentedApr 24, 2022
Following on from #32105 (comment)
Bug report
It is possible for
signal.signal
to throw even when checked againstthreading.main_thread
. For example, in this pattern:For example, in the case when the Python interpreter was started as an embedded interpreter with
Py_InitializeEx(0)
(0 meaning don't register signal handlers), then even though thethreading
check above will succeedsignal.signal
will throw because the "main thread" does not support signals.It was suggested in #32105 (comment) that it might be desirable to add a new API to the
signal
module which would returnTrue
only if the current thread supports signals.The text was updated successfully, but these errors were encountered: