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

Print python stdout without buffer even for script #761

Merged
merged 1 commit into from
Jan 22, 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
3 changes: 1 addition & 2 deletions binaries/daemon/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
let resolved_path = if source_is_url(source) {
// try to download the shared library
let target_dir = Path::new("build");
download_file(source, &target_dir)

Check warning on line 104 in binaries/daemon/src/spawn.rs

View workflow job for this annotation

GitHub Actions / Clippy

this expression creates a reference which is immediately dereferenced by the compiler
.await
.wrap_err("failed to download custom node")?
} else {
Expand All @@ -116,8 +116,6 @@
let python = get_python_path().context("Could not get python path")?;
tracing::info!("spawning: {:?} {}", &python, resolved_path.display());
let mut cmd = tokio::process::Command::new(&python);
// Force python to always flush stdout/stderr buffer
cmd.arg("-u");
cmd.arg(&resolved_path);
cmd
}
Expand Down Expand Up @@ -160,6 +158,7 @@
#[cfg(unix)]
command.process_group(0);

command.env("PYTHONUNBUFFERED", "1");
command
.stdin(Stdio::null())
.stdout(Stdio::piped())
Expand Down Expand Up @@ -341,7 +340,7 @@

// send the buffered lines
let lines = std::mem::take(&mut buffer);
if std::env::var("DORA_QUIET").is_err() {

Check warning on line 343 in binaries/daemon/src/spawn.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` statement can be collapsed
if lines.len() > 1 {
tracing::info!("log_{}: {}", node_id, &lines[..lines.len() - 1]);
}
Expand Down
Loading