From 935a36c6ea49dfd121ce6010e580deeeeeaac996 Mon Sep 17 00:00:00 2001 From: JessicaTegner Date: Sat, 23 Aug 2025 14:27:16 +0200 Subject: [PATCH] python: Acquire GIL on each loop iteration when calling callback --- src/lib-python/src/manager.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib-python/src/manager.rs b/src/lib-python/src/manager.rs index 38bc12d8..62d5d45d 100644 --- a/src/lib-python/src/manager.rs +++ b/src/lib-python/src/manager.rs @@ -63,15 +63,14 @@ impl UpdateManagerWrapper { // Spawn a thread to handle progress updates let progress_thread = thread::spawn(move || { - Python::with_gil(|py| { - while let Ok(progress) = receiver.recv() { + while let Ok(progress) = receiver.recv() { + Python::with_gil(|py| { if let Err(e) = callback.call1(py, (progress,)) { // Log error but continue - don't break the download eprintln!("Progress callback error: {}", e); - break; } - } - }); + }); + } }); // Call download with the sender