improve logging and avoid race

This commit is contained in:
dignifiedquire
2020-03-23 19:49:37 +01:00
parent 01b88f876e
commit 69f1e1753c
2 changed files with 10 additions and 4 deletions

View File

@@ -181,7 +181,7 @@ impl Sql {
let pool = lock.as_ref().ok_or_else(|| Error::SqlNoConnection)?;
let conn = pool.get()?;
let res = async_std::task::spawn_blocking(move || g(conn)).await;
let res = g(conn);
self.in_use.remove();
res
@@ -419,7 +419,10 @@ impl Sql {
let bt = backtrace::Backtrace::new();
eprintln!("old query: {}", query);
eprintln!("Connection is already used from this thread: {:?}", bt);
panic!("Connection is already used from this thread");
panic!(
"Connection is already used from this thread: trying to execute {}",
stmt.as_ref()
);
}
self.in_use.set(stmt.as_ref().to_string());