Skip to content

Commit e6b9f52

Browse files
ctrl+c termination (#8739)
1 parent ca260d9 commit e6b9f52

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

datafusion-cli/Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

datafusion-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ parking_lot = { version = "0.12" }
4545
parquet = { version = "49.0.0", default-features = false }
4646
regex = "1.8"
4747
rustyline = "11.0"
48-
tokio = { version = "1.24", features = ["macros", "rt", "rt-multi-thread", "sync", "parking_lot"] }
48+
tokio = { version = "1.24", features = ["macros", "rt", "rt-multi-thread", "sync", "parking_lot", "signal"] }
4949
url = "2.2"
5050

5151
[dev-dependencies]

datafusion-cli/src/exec.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use datafusion::sql::{parser::DFParser, sqlparser::dialect::dialect_from_str};
4545
use object_store::ObjectStore;
4646
use rustyline::error::ReadlineError;
4747
use rustyline::Editor;
48+
use tokio::signal;
4849
use url::Url;
4950

5051
/// run and execute SQL statements and commands, against a context with the given print options
@@ -165,9 +166,15 @@ pub async fn exec_from_repl(
165166
}
166167
Ok(line) => {
167168
rl.add_history_entry(line.trim_end())?;
168-
match exec_and_print(ctx, print_options, line).await {
169-
Ok(_) => {}
170-
Err(err) => eprintln!("{err}"),
169+
tokio::select! {
170+
res = exec_and_print(ctx, print_options, line) => match res {
171+
Ok(_) => {}
172+
Err(err) => eprintln!("{err}"),
173+
},
174+
_ = signal::ctrl_c() => {
175+
println!("^C");
176+
continue
177+
},
171178
}
172179
// dialect might have changed
173180
rl.helper_mut().unwrap().set_dialect(

0 commit comments

Comments
 (0)