From 9ad9b354f568b78212f6d474320c68adb6250fd9 Mon Sep 17 00:00:00 2001 From: Bas Zalmstra <4995967+baszalmstra@users.noreply.github.com> Date: Thu, 21 Aug 2025 09:59:06 +0200 Subject: [PATCH] fix: occasional hang --- crates/pixi_reporters/src/download_verify_reporter.rs | 8 ++++++-- crates/pixi_reporters/src/main_progress_bar.rs | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/pixi_reporters/src/download_verify_reporter.rs b/crates/pixi_reporters/src/download_verify_reporter.rs index d783230c16..a484e26f9a 100644 --- a/crates/pixi_reporters/src/download_verify_reporter.rs +++ b/crates/pixi_reporters/src/download_verify_reporter.rs @@ -119,8 +119,13 @@ impl BuildDownloadVerifyReporter { // Clear all items that have finished processing. entries.retain(|_, item| !item.is_finished()); + // Drop the write lock to the entries. The progress bar also requires access to + // entries so holding on to the write lock might deadlock! + let is_empty = entries.is_empty(); + drop(entries); + // Clear or update the progress bar. - if entries.is_empty() { + if is_empty { // We cannot clear the progress bar and restart it later, so replacing it with a // new hidden one is currently the only option. self.title = Some(self.pb.prefix()); @@ -130,7 +135,6 @@ impl BuildDownloadVerifyReporter { self.pb.finish_and_clear(); self.pb = new_pb; } else { - drop(entries); self.update() } } diff --git a/crates/pixi_reporters/src/main_progress_bar.rs b/crates/pixi_reporters/src/main_progress_bar.rs index 108aad7612..2cab78e920 100644 --- a/crates/pixi_reporters/src/main_progress_bar.rs +++ b/crates/pixi_reporters/src/main_progress_bar.rs @@ -113,8 +113,13 @@ impl State { // Clear all items that have finished processing. trackers.retain(|_, item| item.finished.is_none()); + // Drop the write lock to the trackers. The progress bar also requires access to + // entries so holding on to the write lock might deadlock! + let is_empty = trackers.is_empty(); + drop(trackers); + // Clear or update the progress bar. - if trackers.is_empty() { + if is_empty { // We cannot clear the progress bar and restart it later, so replacing it with a // new hidden one is currently the only option. self.title = Some(self.pb.prefix()); @@ -124,7 +129,6 @@ impl State { self.pb.finish_and_clear(); self.pb = new_pb; } else { - drop(trackers); self.update() } }