- class ray.util.ActorPool(actors: list)#
Utility class to operate on a fixed pool of actors.
actors – List of Ray actor handles to use in this pool.
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]) print(list(pool.map(lambda a, v: a.double.remote(v), [1, 2, 3, 4])))
[2, 4, 6, 8]
DeveloperAPI: This API may change across minor Ray releases.
Returns the next pending result in order.
Returns any of the next pending results.
Returns whether there are any idle actors available.
Returns whether there are any pending results to return.
Apply the given function in parallel over the actors and values.
Similar to map(), but returning an unordered iterator.
Removes an idle actor from the pool.
Pushes a new actor into the current list of idle actors.
Schedule a single task to run in the pool.