-
Notifications
You must be signed in to change notification settings - Fork 25
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
Bug: The logger swallows exceptions (such as KeyboardInterrupt) #57
Comments
Do you have any information about what the library should be doing differently? I don't think I'm doing anything special about exceptions (so maybe some kind of dealing with them is missing) and the link to discord requires an account… |
No worries! The Discord topic contains the same info as above, but with less detail (without the example).
I believe that when the call to the Python logger returns an exception, it is turned into an Err(PyError) here. That particular Rust function cannot return the exception as an |
I have created a PR that implements a fix. Note that the minimal example also needs an alteration to pick this up: Instead of py.check_signals()?; we need: py.check_signals()?;
match PyErr::take(py) {
None => Ok(()),
Some(err) => Err(err),
}?; because (contrary to what I thought) |
PyO3's logger swallows exceptions.
For example, if while logging you press Ctrl+C, you get a traceback like for instance:
but then the program will continue running.
i.e. the output is akin to
(The exact traceback message changes as it quits in the middle of different Python function calls, but the behaviour of the exception being swallowed remains the same.)
I try to have a well-behaved library that has some long-running calls in Rust and I want the user to be able to interrupt them using Ctrl+C. But
py.check_signals()
does not pick up an exception that was thrown during a call to the PyO3 logger.Minimal Reproducible example repo here.
I previously asked about this behaviour in the PyO3 Discord group, and it was mentioned there that it most likely is a bug.
The text was updated successfully, but these errors were encountered: