distributed 2021.10.0

ParametersBackRef

This returns an iterator that yields the input future objects in the order in which they complete. Calling next on the iterator will block until the next future completes, irrespective of order.

Additionally, you can also add more futures to this object during computation with the .add method

Parameters

futures: Collection of futures :

A list of Future objects to be iterated over in the order in which they complete

with_results: bool (False) :

Whether to wait and include results of futures as well; in this case as_completed yields a tuple of (future, result)

raise_errors: bool (True) :

Whether we should raise when the result of a future raises an exception; only affects behavior when :None:None:`with_results=True`.

Return futures in the order in which they complete

Examples

This example is valid syntax, but we were not able to check execution
>>> x, y, z = client.map(inc, [1, 2, 3])  # doctest: +SKIP
... for future in as_completed([x, y, z]): # doctest: +SKIP
...  print(future.result()) # doctest: +SKIP 3 2 4

Add more futures during computation

This example is valid syntax, but we were not able to check execution
>>> x, y, z = client.map(inc, [1, 2, 3])  # doctest: +SKIP
... ac = as_completed([x, y, z]) # doctest: +SKIP
... for future in ac: # doctest: +SKIP
...  print(future.result()) # doctest: +SKIP
...  if random.random() < 0.5: # doctest: +SKIP
...  ac.add(c.submit(double, future)) # doctest: +SKIP 4 2 8 3 6 12 24

Optionally wait until the result has been gathered as well

This example is valid syntax, but we were not able to check execution
>>> ac = as_completed([x, y, z], with_results=True)  # doctest: +SKIP
... for future, result in ac: # doctest: +SKIP
...  print(result) # doctest: +SKIP 2 4 3
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

distributed.client.as_completed.batches distributed.client.as_completed distributed.client.as_completed.next_batch

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /distributed/client.py#4361
type: <class 'type'>
Commit: