From 49c13ceac3c8fb1a3dbac6ed0c3a010dacc620d3 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 13 Aug 2026 17:00:33 +0100 Subject: [PATCH] Reduce shutdown timeout --- rust/src/runtime.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/src/runtime.rs b/rust/src/runtime.rs index 0eeaf12e5b..caea8adc81 100644 --- a/rust/src/runtime.rs +++ b/rust/src/runtime.rs @@ -34,7 +34,7 @@ use crate::reactor::Reactor; /// How long to wait for in-flight tokio tasks when shutting down with the /// reactor. -const SHUTDOWN_TIMEOUT: Duration = Duration::from_secs(5); +const SHUTDOWN_TIMEOUT: Duration = Duration::from_millis(100); /// State of the lazily-started tokio runtime. enum TokioState { @@ -98,6 +98,8 @@ impl RustRuntimeInner { drop(state); if let TokioState::Running(runtime) = previous_state { + // Shutdown the runtime, waiting for a small grace period for + // in-flight tasks to finish (mimicking Twisted's behaviour). py.detach(|| runtime.shutdown_timeout(SHUTDOWN_TIMEOUT)); }