Cancel waiting tasks on resolution error (#753)

## Summary

I don't understand why this works (because I don't understand why it's
erroring) but it does. See:
https://github.com/astral-sh/puffin/pull/746#issuecomment-1875722454.

## Test Plan

```
cargo run --bin puffin pip-install requires-transitive-incompatible-with-transitive-8329cfc0 --extra-index-url https://test.pypi.org/simple -n
```
This commit is contained in:
Charlie Marsh 2024-01-03 16:18:27 -04:00 committed by GitHub
parent a8e52d2899
commit cfffcbb269
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 1 deletions

View file

@ -24,3 +24,15 @@ pub(crate) struct Index {
/// A map from source URL to precise URL.
pub(crate) redirects: OnceMap<Url, Url>,
}
impl Index {
/// Cancel all waiting tasks.
///
/// Warning: waiting on tasks that have been canceled will cause the index to hang.
pub(crate) fn cancel_all(&self) {
self.packages.cancel_all();
self.distributions.cancel_all();
self.incompatibilities.cancel_all();
self.redirects.cancel_all();
}
}