Bugfix: Fix cli occasionally not printing results (#3509)

This commit is contained in:
Mees Delzenne 2024-02-14 18:37:27 +01:00 committed by GitHub
parent b71f4d1d94
commit 6782b8000a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -153,7 +153,7 @@ pub async fn init(
// Set up the print job // Set up the print job
let (tx, rx) = mpsc::unbounded(); let (tx, rx) = mpsc::unbounded();
tokio::spawn(printer(rx)); let print_task = tokio::spawn(printer(rx));
// Loop over each command-line input // Loop over each command-line input
loop { loop {
@ -246,6 +246,10 @@ pub async fn init(
} }
} }
} }
// drop the printer channel so the printer task will quit.
std::mem::drop(tx);
// print task shouldn't panic or be cancelled so this unwrap should never trigger.
print_task.await.unwrap();
// Save the inputs to the history // Save the inputs to the history
let _ = rl.save_history("history.txt"); let _ = rl.save_history("history.txt");
// Everything OK // Everything OK