get_next#

ActorPool.get_next(timeout: float | None = None, ignore_if_timedout: bool = False)[source]#

Returns the next pending result in order.

This returns the next result produced by submit(), blocking for up to the specified timeout until it is available.

Parameters:
  • timeout (float | None) – Max seconds to wait for the next result. None waits indefinitely.

  • ignore_if_timedout (bool) – When True, drop the timed-out task and raise TimeoutError after advancing past it instead of leaving it in place.

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