mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-29 05:24:46 +00:00
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:
parent
a8e52d2899
commit
cfffcbb269
3 changed files with 24 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,7 +202,11 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> {
|
|||
}
|
||||
resolution = resolve_fut => {
|
||||
resolution.map_err(|err| {
|
||||
// Add version information to improve unsat error messages
|
||||
// Ensure that any waiting tasks are cancelled prior to accessing any of the
|
||||
// index entries.
|
||||
self.index.cancel_all();
|
||||
|
||||
// Add version information to improve unsat error messages.
|
||||
if let ResolveError::NoSolution(err) = err {
|
||||
ResolveError::NoSolution(err.with_available_versions(&self.python_requirement, &self.index.packages).with_selector(self.selector.clone()))
|
||||
} else {
|
||||
|
|
|
@ -71,6 +71,13 @@ impl<K: Eq + Hash, V> OnceMap<K, V> {
|
|||
{
|
||||
self.wait_map.get(key)
|
||||
}
|
||||
|
||||
/// Cancel all waiting tasks.
|
||||
///
|
||||
/// Warning: waiting on tasks that have been canceled will cause the map to hang.
|
||||
pub fn cancel_all(&self) {
|
||||
self.wait_map.cancel_all();
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash + Clone, V> Default for OnceMap<K, V> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue