From 6782b8000aaffbd6a7a40837a7b199f7bbaf1fb0 Mon Sep 17 00:00:00 2001 From: Mees Delzenne Date: Wed, 14 Feb 2024 18:37:27 +0100 Subject: [PATCH] Bugfix: Fix cli occasionally not printing results (#3509) --- src/cli/sql.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cli/sql.rs b/src/cli/sql.rs index faba140d..65a93c19 100644 --- a/src/cli/sql.rs +++ b/src/cli/sql.rs @@ -153,7 +153,7 @@ pub async fn init( // Set up the print job let (tx, rx) = mpsc::unbounded(); - tokio::spawn(printer(rx)); + let print_task = tokio::spawn(printer(rx)); // Loop over each command-line input 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 let _ = rl.save_history("history.txt"); // Everything OK