-
Notifications
You must be signed in to change notification settings - Fork 6.9k
[Feat] cancel sync actor by checking is_canceled() #58914
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
machichima
wants to merge
7
commits into
ray-project:master
Choose a base branch
from
machichima:58213-cancel-sync-actor-from-cpp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Feat] cancel sync actor by checking is_canceled() #58914
machichima
wants to merge
7
commits into
ray-project:master
from
machichima:58213-cancel-sync-actor-from-cpp
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
00c14b3 to
4064df3
Compare
Signed-off-by: machichima <[email protected]>
4064df3 to
80a610d
Compare
Signed-off-by: machichima <[email protected]>
Signed-off-by: machichima <[email protected]>
machichima
commented
Nov 23, 2025
Comment on lines
+677
to
+684
| RAY_LOG(INFO) << "Task " << task_id << " completed but was cancelled, failing it"; | ||
| rpc::RayErrorInfo error_info; | ||
| std::ostringstream error_message; | ||
| error_message << "Task: " << task_id.Hex() << " was cancelled."; | ||
| error_info.set_error_message(error_message.str()); | ||
| error_info.set_error_type(rpc::ErrorType::TASK_CANCELLED); | ||
| task_manager_.FailPendingTask( | ||
| task_id, rpc::ErrorType::TASK_CANCELLED, nullptr, &error_info); |
Contributor
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to make ray.get() also raising TaskCanceled error for canceled sync task here.
I don't think this the best way handling it. Please let me know if there's a better way or where can I look into 🙏
Contributor
Author
|
cc @edoakes @Sparks0219 PTAL. Thank you! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
community-contribution
Contributed by the community
core
Issues that should be addressed in Ray Core
usability
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Enable sync actors to detect task cancellation during execution via
ray.get_runtime_context().is_canceled()API for graceful terminationMain changes:
Record task cancellation in executor:
core_worker.cccanceled_tasks_and expose it to Python API throughIsTaskCanceled()runtime_context.pyis_canceled()API that callsCoreWorker::IsTaskCanceled()following pathworker.py->_raylet.pyx->core_worker.ccRaise cancellation error when using
ray.get()(on submitter side)actor_task_submitter.ccTaskManager::IsTaskCanceled()), explicitly setTASK_CANCELLEDerrortask_manager.ccIsTaskCanceled()to exposeis_canceled_flagRelated issues
Related to #58213
Additional information
Tested with following example:
Result screenshot: