Browse Source

Force python run unbuffered print to avoid having to use flush=True within python

tags/0.3.8-rc
haixuantao 1 year ago
parent
commit
31c0e76f8a
2 changed files with 5 additions and 1 deletions
  1. +4
    -0
      binaries/daemon/src/spawn.rs
  2. +1
    -1
      libraries/core/src/lib.rs

+ 4
- 0
binaries/daemon/src/spawn.rs View File

@@ -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
}
@@ -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(),


+ 1
- 1
libraries/core/src/lib.rs View File

@@ -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 {


Loading…
Cancel
Save