get_next_unordered#
- ActorPool.get_next_unordered(timeout: float | None = None, ignore_if_timedout: bool = False)[source]#
Returns any of the next pending results.
This returns some result produced by submit(), blocking for up to the specified timeout until it is available. Unlike get_next(), the results are not always returned in same order as submitted, which can improve performance.
- Parameters:
- Returns:
The next result.
- Raises:
TimeoutError – if the timeout is reached.
Examples
>>> import ray >>> from ray.util.actor_pool import ActorPool >>> @ray.remote ... class Actor: ... def double(self, v): ... return 2 * v >>> a1, a2 = Actor.remote(), Actor.remote() >>> pool = ActorPool([a1, a2]) >>> pool.submit(lambda a, v: a.double.remote(v), 1) >>> pool.submit(lambda a, v: a.double.remote(v), 2) >>> results = [pool.get_next_unordered(), pool.get_next_unordered()] >>> set(results) == {2, 4} True