fix(python): detach background spawns with drop, not let _

`cargo clippy --all-features --tests` fails on `clippy::let_underscore_future`
for both spawns in `spawn_background`, which breaks the Rust lint job. It is
failing on main as well, not just here, so the Node matrix never runs: fail-fast
cancels it before it starts.

Discarding a `JoinHandle` leaves the task running, which is what
`spawn_background` is for, and the `OutstandingGuard` the task carries is what
keeps it visible to `shutdown`. `drop` says that; `let _ =` reads as throwing
away an unpolled future, which is what the lint is for.
This commit is contained in:
Jack Ye
2026-09-23 21:39:30 -07:00
parent 1f3a24b594
commit 75ccb9f830
+5 -6
View File
@@ -208,13 +208,12 @@ where
let _guard = guard;
fut.await;
};
// Detaching is the point: dropping the `JoinHandle` leaves the task running, and the
// `OutstandingGuard` it carries is what keeps it visible to `shutdown`. Written as `drop`
// rather than `let _ =`, which reads as discarding an unpolled future.
match runtime::Handle::try_current() {
Ok(handle) => {
let _ = handle.spawn(task);
}
Err(_) => {
let _ = get_runtime().spawn(task);
}
Ok(handle) => drop(handle.spawn(task)),
Err(_) => drop(get_runtime().spawn(task)),
}
}