mirror of
https://github.com/wassname/ray.git
synced 2026-07-10 18:47:36 +08:00
Update named actor API (#8559)
This commit is contained in:
+21
-7
@@ -1657,7 +1657,22 @@ def wait(object_ids, num_returns=1, timeout=None):
|
||||
return ready_ids, remaining_ids
|
||||
|
||||
|
||||
def kill(actor):
|
||||
def get_actor(name):
|
||||
"""Get a handle to a detached actor.
|
||||
|
||||
Gets a handle to a detached actor with the given name. The actor must
|
||||
have been created with Actor.options(name="name").remote().
|
||||
|
||||
Returns:
|
||||
ActorHandle to the actor.
|
||||
|
||||
Raises:
|
||||
ValueError if the named actor does not exist.
|
||||
"""
|
||||
return ray.util.named_actors._get_actor(name)
|
||||
|
||||
|
||||
def kill(actor, no_restart=True):
|
||||
"""Kill an actor forcefully.
|
||||
|
||||
This will interrupt any running tasks on the actor, causing them to fail
|
||||
@@ -1667,21 +1682,20 @@ def kill(actor):
|
||||
you can call ``actor.__ray_terminate__.remote()`` instead to queue a
|
||||
termination task.
|
||||
|
||||
In both cases, the worker is actually killed, but it will be restarted by
|
||||
Ray.
|
||||
|
||||
If this actor is reconstructable, an attempt will be made to reconstruct
|
||||
it.
|
||||
If the actor is a detached actor, subsequent calls to get its handle via
|
||||
ray.get_actor will fail.
|
||||
|
||||
Args:
|
||||
actor (ActorHandle): Handle to the actor to kill.
|
||||
no_restart (bool): Whether or not this actor should be restarted if
|
||||
it's a restartable actor.
|
||||
"""
|
||||
if not isinstance(actor, ray.actor.ActorHandle):
|
||||
raise ValueError("ray.kill() only supported for actors. "
|
||||
"Got: {}.".format(type(actor)))
|
||||
worker = ray.worker.global_worker
|
||||
worker.check_connected()
|
||||
worker.core_worker.kill_actor(actor._ray_actor_id, False)
|
||||
worker.core_worker.kill_actor(actor._ray_actor_id, no_restart)
|
||||
|
||||
|
||||
def cancel(object_id, force=False):
|
||||
|
||||
Reference in New Issue
Block a user