Skip to content

Commit

Permalink
Print python stdout without buffer even for script (#761)
Browse files Browse the repository at this point in the history
Adding ** PYTHONUNBUFFERED=1** makes python script print out to stdout
without buffering.

Previously this was fixed with a python flag but that was not called
when python was used as a script.

This resolve the previous issue.
  • Loading branch information
haixuanTao authored Jan 22, 2025
2 parents 18d26d1 + 3e2613a commit 69e5cd7
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions binaries/daemon/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ pub async fn spawn_node(
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 @@ pub async fn spawn_node(
#[cfg(unix)]
command.process_group(0);

command.env("PYTHONUNBUFFERED", "1");
command
.stdin(Stdio::null())
.stdout(Stdio::piped())
Expand Down

0 comments on commit 69e5cd7

Please sign in to comment.