ray.util.ActorPool.has_free#
- ActorPool.has_free()[源代码]#
返回是否有任何空闲的演员可用。
- 返回:
如果存在任何空闲的执行者且没有待处理的提交,则为真。
示例
import ray from ray.util.actor_pool import ActorPool @ray.remote class Actor: def double(self, v): return 2 * v a1 = Actor.remote() pool = ActorPool([a1]) pool.submit(lambda a, v: a.double.remote(v), 1) print(pool.has_free()) print(pool.get_next()) print(pool.has_free())
False 2 True