Skip to content

Commit

Permalink
Force python run unbuffered print to avoid having to use flush=True w…
Browse files Browse the repository at this point in the history
…ithin python
  • Loading branch information
haixuanTao committed Dec 6, 2024
1 parent e489cf1 commit 31c0e76
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions binaries/daemon/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ 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 @@ -221,6 +223,8 @@ pub async fn spawn_node(
let python = get_python_path()
.context("Could not find python path when spawning runtime node")?;
let mut command = tokio::process::Command::new(python);
// Force python to always flush stdout/stderr buffer
command.arg("-u");
command.args([
"-c",
format!("import dora; dora.start_runtime() # {}", node.id).as_str(),
Expand Down
2 changes: 1 addition & 1 deletion libraries/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn adjust_shared_library_path(path: &Path) -> Result<std::path::PathBuf, eyr
// Search for python binary.
// Match `python` for windows and macos and `python3` for other platforms.
pub fn get_python_path() -> Result<std::path::PathBuf, eyre::ErrReport> {
let python = if cfg!(windows) || cfg!(target_os = "macos") {
let python = if cfg!(windows) || cfg!(target_os = "macos") {
which::which("python")
.context("failed to find `python` or `python3`. Make sure that python is available.")?
} else {
Expand Down

0 comments on commit 31c0e76

Please sign in to comment.