Fix sidecar stdout buffering: set PYTHONUNBUFFERED=1
All checks were successful
All checks were successful
PyInstaller frozen executables buffer stdout when piped to a subprocess (no TTY). Even with flush=True in Python, the OS-level pipe buffer can delay output. This prevented the ready event from reaching the Tauri app, causing the "Starting sidecar..." hang. Fix: set PYTHONUNBUFFERED=1 env var on both prod and dev sidecar commands, plus -u flag for dev mode Python. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -555,7 +555,7 @@ impl SidecarManager {
|
|||||||
|
|
||||||
fn build_dev_command(&self) -> Result<std::process::Command, String> {
|
fn build_dev_command(&self) -> Result<std::process::Command, String> {
|
||||||
let mut cmd = std::process::Command::new("python");
|
let mut cmd = std::process::Command::new("python");
|
||||||
cmd.args(["-m", "backend.main_headless"]);
|
cmd.args(["-u", "-m", "backend.main_headless"]); // -u = unbuffered
|
||||||
|
|
||||||
// Try to find the project root (parent of src-tauri)
|
// Try to find the project root (parent of src-tauri)
|
||||||
if let Some(dirs) = DIRS.get() {
|
if let Some(dirs) = DIRS.get() {
|
||||||
@@ -568,6 +568,7 @@ impl SidecarManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.env("PYTHONUNBUFFERED", "1");
|
||||||
Ok(cmd)
|
Ok(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,6 +584,9 @@ impl SidecarManager {
|
|||||||
bin.parent()
|
bin.parent()
|
||||||
.ok_or("Cannot determine sidecar parent dir")?,
|
.ok_or("Cannot determine sidecar parent dir")?,
|
||||||
);
|
);
|
||||||
|
// Force unbuffered stdout so the ready event is sent immediately.
|
||||||
|
// PyInstaller frozen executables buffer stdout when piped.
|
||||||
|
cmd.env("PYTHONUNBUFFERED", "1");
|
||||||
Ok(cmd)
|
Ok(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user