ray.util.ActorPool.get_next_unordered#

ActorPool.get_next_unordered(timeout=None, ignore_if_timedout=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.

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)
print(pool.get_next_unordered())
print(pool.get_next_unordered())
4
2