From 01f4beeafe72baee8049dcc5db3a4c9d18129390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 3 Sep 2024 10:32:43 +0200 Subject: [PATCH] Differentiate startup and compile timeouts (#6958) ## Summary Separate exceptions for different timeouts to make it easier to debug issues like #6105. ## Test Plan Not tested at all. --- crates/uv-installer/src/compile.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/crates/uv-installer/src/compile.rs b/crates/uv-installer/src/compile.rs index 29bc947a5..182b131ab 100644 --- a/crates/uv-installer/src/compile.rs +++ b/crates/uv-installer/src/compile.rs @@ -48,7 +48,9 @@ pub enum CompileError { err: Box, }, #[error("Bytecode timed out ({}s)", _0.as_secs_f32())] - Timeout(Duration), + CompileTimeout(Duration), + #[error("Python startup timed out ({}s)", _0.as_secs_f32())] + StartupTimeout(Duration), } /// Bytecode compile all file in `dir` using a pool of Python interpreters running a Python script @@ -194,7 +196,7 @@ async fn worker( let (mut bytecode_compiler, child_stdin, mut child_stdout, mut child_stderr) = tokio::time::timeout(COMPILE_TIMEOUT, wait_until_ready) .await - .map_err(|_| CompileError::Timeout(COMPILE_TIMEOUT))??; + .map_err(|_| CompileError::StartupTimeout(COMPILE_TIMEOUT))??; let stderr_reader = tokio::task::spawn(async move { let mut child_stderr_collected: Vec = Vec::new(); @@ -355,7 +357,7 @@ async fn worker_main_loop( // should ever take. tokio::time::timeout(COMPILE_TIMEOUT, python_handle) .await - .map_err(|_| CompileError::Timeout(COMPILE_TIMEOUT))??; + .map_err(|_| CompileError::CompileTimeout(COMPILE_TIMEOUT))??; // This is a sanity check, if we don't get the path back something has gone wrong, e.g. // we're not actually running a python interpreter.