Principle:Ray project Ray Actor Termination
| Knowledge Sources | |
|---|---|
| Domains | Distributed_Computing, Resource_Management |
| Last Updated | 2026-02-13 17:00 GMT |
Overview
A mechanism for terminating remote actor processes, either externally via a kill signal or internally via a self-exit within the actor.
Description
Actor Termination provides two complementary approaches to stopping an actor:
- External kill: The actor's owner (or any holder of the handle) sends a kill signal, forcibly stopping the actor process. The noRestart parameter controls whether the actor should be automatically restarted.
- Self-exit: The actor code itself initiates a graceful exit from within a method call. This is used for controlled shutdown scenarios where the actor decides to terminate based on its internal state.
After termination, subsequent calls to the actor will raise RayActorException.
Usage
Use external kill when you need to stop an actor from the outside (e.g., resource cleanup, redeployment). Use self-exit when the actor should terminate itself based on internal logic (e.g., job completion, error recovery).
Theoretical Basis
Actor termination relates to actor supervision in the actor model. The two approaches correspond to:
- Supervised termination: A supervisor (handle owner) decides to stop the actor
- Self-termination: The actor decides to stop itself
The restart policy (maxRestarts) determines whether the supervisor should automatically recreate the actor after termination.