Skip to content
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

fix(processing_engine): ensure default SIGINT behavior from python. #25957

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion influxdb3_processing_engine/src/virtualenv.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use observability_deps::tracing::debug;
use pyo3::Python;
use std::ffi::CString;
use std::path::Path;
use std::process::Command;
use std::sync::Once;
Expand Down Expand Up @@ -46,8 +48,21 @@ fn set_pythonpath(venv_dir: &Path) -> Result<(), std::io::Error> {
pub fn init_pyo3() {
PYTHON_INIT.call_once(|| {
pyo3::prepare_freethreaded_python();
})

// This sets the signal handler fo SIGINT to be the default, allowing CTRL+C to work.
// See https://github.com/PyO3/pyo3/issues/3218.
Python::with_gil(|py| {
py.run(
&CString::new("import signal;signal.signal(signal.SIGINT, signal.SIG_DFL)")
.unwrap(),
None,
None,
)
.expect("should be able to set signal handler.");
});
});
}

#[cfg(unix)]
pub(crate) fn initialize_venv(venv_path: &Path) -> Result<(), VenvError> {
use std::process::Command;
Expand Down