Fix delay/hang when resolving deep dictionary dependencies #3460
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.
Description
Prior to this PR, the
dict
part ofDEEP_DEPENDENCY_RESOLVER
did not extract all futures that it should in the gather stage, meaning that sometimes the unwrap stage would happen too early. Prior to this PR, only keys and values of adict
that were directlyFuture
objects would be waited for by the DFK, rather than deep-recursing into those key/value objects. This would result inFuture.result()
happening too early (and blocking, potentially forever).This PR switches out that behaviour to call deep_traverse_to_gather recursively, instead of using an
if
.This PR adds a test case which demonstrates this change. That test case will hang without the above change, but pass with this change.
This PR adds asserts to the code that unwraps
Future
objects, to assert that the future object is in a suitable state for immediate unwrapping (i.e. that it isdone()
). This changes the above bug from a hang into a dependency failure that is reported to the user, and because it happens in any unwrapping ofFuture
objects, is probably useful in the future to anyone modifying on the deep dependency resolver.Type of change