-
Notifications
You must be signed in to change notification settings - Fork 802
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
Cannot stop rust program while running python code #3218
Comments
Could you share some code showing what exactly you are doing? For example, doesn't Python raise an exception when the signal is received? Where is that exception handled? |
Sorry for few information. I think the CTRL-C is captured at python side, and thought That shouldn't happen since It's blocking input to main process, But I'll investigate more and re-open issue. Thank you for reply |
You can disable Python's
|
@birkenfeld Thank you for your kind help :) |
To do it from Rust: Python::with_gil(|py| {
py.run(
r#"
import signal
print("[python] Ignoring system signals")
signal.signal(signal.SIGINT, signal.SIG_DFL)
"#,
None,
None,
)
.unwrap();
}); |
Bug Description
When I run python code in fast loop from rust and want to stop the program, python takes interrupt so rust program won't exit.
Steps to Reproduce
Run python code in Rust
Backtrace
No response
Your operating system and version
tested in mac, linux
Your Python version (
python --version
)Python 3.11.3
Your Rust version (
rustc --version
)rustc 1.70.0 (90c541806 2023-05-31)
Your PyO3 version
0.19.0
How did you install python? Did you use a virtualenv?
mac with brew
and apt for linux
Additional Info
Thank you.
The text was updated successfully, but these errors were encountered: