From c3fc2a06bdb7ee74639e71db0fa41b51696c251f Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 15 Nov 2024 01:11:17 +0100 Subject: [PATCH] delete venv folder if pip install didn't succeed --- backend/windmill-worker/src/python_executor.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/backend/windmill-worker/src/python_executor.rs b/backend/windmill-worker/src/python_executor.rs index b06f30b98d..c2b5dce572 100644 --- a/backend/windmill-worker/src/python_executor.rs +++ b/backend/windmill-worker/src/python_executor.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, process::Stdio}; +use std::{collections::HashMap, fs, process::Stdio}; use itertools::Itertools; use regex::Regex; @@ -1326,6 +1326,16 @@ pub async fn handle_python_reqs( "finished setting up python dependencies {}", job_id ); + if child.is_err() { + + if let Err(e) = fs::remove_dir_all(&venv_p) { + tracing::warn!( + workspace_id = %w_id, + "failed to remove cache dir: {:?}", + e + ); + } + } child?; #[cfg(all(feature = "enterprise", feature = "parquet"))]