From 460981104577cb2f2b814055bda5a4e4a6e7dc65 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Wed, 3 May 2023 11:09:21 +0200 Subject: [PATCH] fix: drop tokio runtime on separate thread (#2531) --- bin/reth/src/runner.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/reth/src/runner.rs b/bin/reth/src/runner.rs index e378f3bb00..315508c578 100644 --- a/bin/reth/src/runner.rs +++ b/bin/reth/src/runner.rs @@ -75,6 +75,12 @@ impl CliRunner { let fut = tokio_runtime.handle().spawn_blocking(move || handle.block_on(fut)); tokio_runtime .block_on(run_until_ctrl_c(async move { fut.await.expect("Failed to join task") }))?; + + // drop the tokio runtime on a separate thread because drop blocks until its pools + // (including blocking pool) are shutdown. In other words `drop(tokio_runtime)` would block + // the current thread but we want to exit right away. + std::thread::spawn(move || drop(tokio_runtime)); + Ok(()) } }