Skip to content

Commit

Permalink
improving error handling of init_globals
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhawvipul committed Aug 8, 2024
1 parent 8b2b501 commit 6de836d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/duckdb/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@ fn init_globals() {
let mut signals =
Signals::new([SIGTERM, SIGINT, SIGQUIT]).expect("error registering signal listener");
for _ in signals.forever() {
let conn = get_global_connection().expect("failed to get connection");
let conn = conn.lock().unwrap();
conn.interrupt();
match get_global_connection() {
Ok(conn) => {
if let Err(err) = conn.lock() {
eprintln!("Failed to acquire lock for connection: {}", err);
continue;
}
let conn = conn.lock().unwrap();
conn.interrupt();
}
Err(err) => eprintln!("Failed to get global connection: {}", err),
}
}
});
}
Expand Down

0 comments on commit 6de836d

Please sign in to comment.