Skip to content

Commit

Permalink
Address comment: Don't change behavior for non-async actor
Browse files Browse the repository at this point in the history
Closes: ray-project#49451
Signed-off-by: Chi-Sheng Liu <chishengliu@chishengliu.com>
  • Loading branch information
MortalHappiness committed Feb 28, 2025
1 parent 2dece2d commit 1ee13ec
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions python/ray/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
STREAMING_GENERATOR_RETURN,
ObjectRefGenerator,
PythonFunctionDescriptor,
raise_sys_exit_with_custom_error_message,
)
from ray.util.annotations import DeveloperAPI, PublicAPI
from ray.util.placement_group import _configure_placement_group_based_on_context
Expand Down Expand Up @@ -1766,9 +1767,11 @@ def exit_actor():
This API can be used only inside an actor. Use ray.kill
API if you'd like to kill an actor using actor handle.
When the API is called, the actor sets a flag to exit.
The worker periodically checks the flag and exits the actor.
So there may be some delay before the actor actually exits.
When the API is called, if the actor it not async actor,
it raises an exception and exits. For async actor,
it sets a flag to exit and the worker periodically checks
the flag and exits the actor. So there may be some delay
before the actor actually exits.
Any queued methods will fail. Any ``atexit``
handlers installed in the actor will be run.
Expand All @@ -1783,4 +1786,6 @@ def exit_actor():
f"{worker.mode}. Call this API inside an actor methods"
"if you'd like to exit the actor gracefully."
)
if not worker.core_worker.current_actor_is_asyncio():
raise_sys_exit_with_custom_error_message("exit_actor() is called.")
worker.core_worker.set_current_actor_should_exit()

0 comments on commit 1ee13ec

Please sign in to comment.