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.
Adding several helper functions:
Same as
asyncio.gather
but it is possible to safely pass Nones through.If any of the tasks fails – others are cancelled. Allows to wait for the completion of the cancelled tasks. Returns a list of values or raises the first exception.
If any of the tasks fails – it is ok. Allows to wait for the completion of the cancelled tasks in the case of external cancellation. Returns a list of values or exceptions.
Gather tasks in two groups - primary and secondary. If any primary is somehow failed, then, other tasks are cancelled. If secondary is failed – it is ok. If any primary is failed, then, will raise the first exception. Returns two lists of results, one for the primary tasks (only values) and the other for the secondary tasks (values or exceptions). If only
primary
orsecondary
is passed, then, returns a single list.Main logic is the same as for
gather_graceful
.Similar to
asyncio.wait
, but particularly waits for the first cancelled or failed task.