mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-02 00:36:53 +00:00
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:
@@ -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)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user