From fe8d55dba9cf06214845bdc5e9d106ba2c2b9f82 Mon Sep 17 00:00:00 2001 From: Nicolas Patry Date: Mon, 21 Oct 2024 14:49:07 +0200 Subject: [PATCH] Clean both threads. --- launcher/src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/launcher/src/main.rs b/launcher/src/main.rs index d52b862e..c6898901 100644 --- a/launcher/src/main.rs +++ b/launcher/src/main.rs @@ -1263,7 +1263,7 @@ fn download_convert_model( let download_stdout = BufReader::new(download_process.stdout.take().unwrap()); - let t = thread::spawn(move || { + let stdout_thread = thread::spawn(move || { log_lines(download_stdout); }); @@ -1271,7 +1271,7 @@ fn download_convert_model( // We read stderr in another thread as it seems that lines() can block in some cases let (err_sender, err_receiver) = mpsc::channel(); - thread::spawn(move || { + let stderr_thread = thread::spawn(move || { for line in download_stderr.lines().map_while(Result::ok) { err_sender.send(line).unwrap_or(()); } @@ -1305,7 +1305,8 @@ fn download_convert_model( } sleep(Duration::from_millis(100)); } - t.join().expect("Closing log reading thread"); + stdout_thread.join().expect("Closing log reading thread"); + stderr_thread.join().expect("Closing log reading thread"); Ok(()) }