-
Notifications
You must be signed in to change notification settings - Fork 802
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add wrapper for PyErr_CheckSignals() to Python. #1214
Conversation
Looks good but we have to fix PyPy CI first (it's unrelated to this patch, though). |
CI actually only prevents merging if any of the python 3.8 jobs fail atm, so no need to rebase on #1215. I was going to ask though - should this api be |
Well IMO this only has a marginal connection to PyErr and exception handling, and the C version is named unfortunately. It's rather an interpreter related thing. In newer Pythons, they added APIs with PySignal_ prefix but this didn't exist back then. |
👍 I think it's ok to let a test slide on this one for now as it's a complicated test to write, and this is basically just wrapping the C-API? Could use a CHANGELOG entry stating the addition of the new method. |
/// Lets the Python interpreter check for pending signals and invoke the | ||
/// corresponding signal handlers. This can run arbitrary Python code. | ||
/// | ||
/// If an exception is raised by the signal handler, or the default signal | ||
/// handler raises an exception (such as `KeyboardInterrupt` for `SIGINT`), | ||
/// an `Err` is returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this doc maybe also mention that it's a safe wrapper about PyErr_CheckSignals
? I think it can be helpful for some people to know this without having to look at the source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
This is a useful API in long-running Rust code, which lets users cancel evaluation by pressing Ctrl-C, and run any other signal handlers that have been set using the signal module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I don't know how to test this...