(&mut self)
| 352 | |
| 353 | impl Drop for LocalInstance { |
| 354 | fn drop(&mut self) { |
| 355 | if let Some(runtime) = self.runtime.take() { |
| 356 | // Tokio runtimes cannot perform their blocking shutdown while they are being dropped |
| 357 | // from another runtime's async context. `LocalInstance` is commonly owned directly by |
| 358 | // async tests, so shut down and drop its runtime on a plain thread before cleaning up |
| 359 | // the resources it owns. The node and pool hold `Runtime` clones (it is an `Arc`), so |
| 360 | // they must be dropped on that thread too, or the last reference, and with it the |
| 361 | // tokio runtime, is released here in async context. Dropping them also releases their |
| 362 | // database handles before the backing files are removed below. |
| 363 | let node_handle = self.node_handle.take(); |
| 364 | let pool_handle = self.pool_handle.take(); |
| 365 | let shutdown = std::thread::spawn(move || { |
| 366 | runtime.graceful_shutdown_with_timeout(Duration::from_secs(10)); |
| 367 | drop(node_handle); |
| 368 | drop(pool_handle); |
| 369 | drop(runtime); |
| 370 | }); |
| 371 | if let Err(panic) = shutdown.join() { |
| 372 | std::panic::resume_unwind(panic); |
| 373 | } |
| 374 | if let Err(e) = std::fs::remove_dir_all(self.node_config().datadir().to_string()) { |
| 375 | eprintln!( |
| 376 | "Warning: failed to remove temporary data directory {}: {e}", |
| 377 | self.node_config().datadir() |
| 378 | ); |
| 379 | } |
| 380 | if let Err(e) = std::fs::remove_dir_all(&self.db_dir) { |
| 381 | eprintln!( |
| 382 | "Warning: failed to remove temporary database directory {}: {e}", |
| 383 | self.db_dir.display() |
| 384 | ); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | impl Future for LocalInstance { |
nothing calls this directly
no test coverage detected