submit#
- ActorPool.submit(fn: Callable[[ActorHandle, V], Any], value: V)[source]#
Schedule a single task to run in the pool.
This has the same argument semantics as map(), but takes on a single value instead of a list of values. The result can be retrieved using get_next() / get_next_unordered().
- Parameters:
fn (Callable[[ActorHandle, V], Any]) – Function that takes (actor, value) as argument and returns an ObjectRef computing the result over the value. The actor will be considered busy until the ObjectRef completes.
value (V) – Value to compute a result for.
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(), pool.get_next()) 2 4