-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wait for request stream to flush before returning resolution #2374
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ use pubgrub::error::PubGrubError; | |
use pubgrub::range::Range; | ||
use pubgrub::solver::{Incompatibility, State}; | ||
use rustc_hash::{FxHashMap, FxHashSet}; | ||
use tokio::select; | ||
use tokio_stream::wrappers::ReceiverStream; | ||
use tracing::{debug, info_span, instrument, trace, Instrument}; | ||
use url::Url; | ||
|
@@ -197,42 +196,40 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
let requests_fut = self.fetch(request_stream).fuse(); | ||
|
||
// Run the solver. | ||
let resolve_fut = self.solve(&request_sink).fuse(); | ||
let resolve_fut = self.solve(request_sink).fuse(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking ownership means that |
||
|
||
let resolution = select! { | ||
result = requests_fut => { | ||
result?; | ||
return Err(ResolveError::ChannelClosed); | ||
// Wait for both to complete. | ||
match tokio::try_join!(requests_fut, resolve_fut) { | ||
Ok(((), resolution)) => { | ||
self.on_complete(); | ||
Ok(resolution) | ||
} | ||
resolution = resolve_fut => { | ||
resolution.map_err(|err| { | ||
// Add version information to improve unsat error messages. | ||
if let ResolveError::NoSolution(err) = err { | ||
ResolveError::NoSolution( | ||
err | ||
.with_available_versions(&self.python_requirement, &self.visited, &self.index.packages) | ||
.with_selector(self.selector.clone()) | ||
.with_python_requirement(&self.python_requirement) | ||
.with_index_locations(self.provider.index_locations()) | ||
.with_unavailable_packages(&self.unavailable_packages) | ||
Err(err) => { | ||
// Add version information to improve unsat error messages. | ||
Err(if let ResolveError::NoSolution(err) = err { | ||
ResolveError::NoSolution( | ||
err.with_available_versions( | ||
&self.python_requirement, | ||
&self.visited, | ||
&self.index.packages, | ||
) | ||
} else { | ||
err | ||
} | ||
})? | ||
.with_selector(self.selector.clone()) | ||
.with_python_requirement(&self.python_requirement) | ||
.with_index_locations(self.provider.index_locations()) | ||
.with_unavailable_packages(&self.unavailable_packages), | ||
) | ||
} else { | ||
err | ||
}) | ||
} | ||
}; | ||
|
||
self.on_complete(); | ||
|
||
Ok(resolution) | ||
} | ||
} | ||
|
||
/// Run the `PubGrub` solver. | ||
#[instrument(skip_all)] | ||
async fn solve( | ||
&self, | ||
request_sink: &tokio::sync::mpsc::Sender<Request>, | ||
request_sink: tokio::sync::mpsc::Sender<Request>, | ||
) -> Result<ResolutionGraph, ResolveError> { | ||
let root = PubGrubPackage::Root(self.project.clone()); | ||
|
||
|
@@ -258,7 +255,7 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
// Pre-visit all candidate packages, to allow metadata to be fetched in parallel. If | ||
// the dependency mode is direct, we only need to visit the root package. | ||
if self.dependency_mode.is_transitive() { | ||
Self::pre_visit(state.partial_solution.prioritized_packages(), request_sink) | ||
Self::pre_visit(state.partial_solution.prioritized_packages(), &request_sink) | ||
.await?; | ||
} | ||
|
||
|
@@ -294,7 +291,7 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
&next, | ||
term_intersection.unwrap_positive(), | ||
&mut pins, | ||
request_sink, | ||
&request_sink, | ||
) | ||
.await?; | ||
|
||
|
@@ -434,7 +431,7 @@ impl<'a, Provider: ResolverProvider> Resolver<'a, Provider> { | |
// Retrieve that package dependencies. | ||
let package = &next; | ||
let dependencies = match self | ||
.get_dependencies(package, &version, &mut priorities, request_sink) | ||
.get_dependencies(package, &version, &mut priorities, &request_sink) | ||
.await? | ||
{ | ||
Dependencies::Unavailable(reason) => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the panic message to all the broken channel cases because in my experience this error happens when there was a panic in another thread, so the error message you get is ~irrelevant, while scrolling up another thread spilled a first panic to stderr that has the actually relevant failure