mirror of
https://github.com/wassname/ray.git
synced 2026-07-12 04:40:55 +08:00
Add actor.__ray_kill__() to terminate actors immediately (#6523)
This commit is contained in:
+15
-1
@@ -642,7 +642,7 @@ class ActorHandle(object):
|
||||
self._actor_id.hex())
|
||||
|
||||
def __del__(self):
|
||||
"""Kill the worker that is running this actor."""
|
||||
"""Terminate the worker that is running this actor."""
|
||||
# TODO(swang): Also clean up forked actor handles.
|
||||
# Kill the worker if this is the original actor handle, created
|
||||
# with Class.remote(). TODO(rkn): Even without passing handles around,
|
||||
@@ -671,6 +671,20 @@ class ActorHandle(object):
|
||||
finally:
|
||||
self.__ray_terminate__._actor_hard_ref = None
|
||||
|
||||
def __ray_kill__(self):
|
||||
"""Kill the actor that this actor handle refers to immediately.
|
||||
|
||||
This will cause any outstanding tasks submitted to the actor to fail
|
||||
and the actor to exit in the same way as if it crashed. In general,
|
||||
you should prefer to just delete the actor handle and let it clean up
|
||||
gracefull.
|
||||
|
||||
Returns:
|
||||
None.
|
||||
"""
|
||||
worker = ray.worker.get_global_worker()
|
||||
worker.core_worker.kill_actor(self._ray_actor_id)
|
||||
|
||||
@property
|
||||
def _actor_id(self):
|
||||
return self._ray_actor_id
|
||||
|
||||
Reference in New Issue
Block a user