mirror of
https://github.com/wassname/ray.git
synced 2026-07-11 22:51:24 +08:00
TaskCancellation (#7669)
* Smol comment * WIP, not passing ray.init * Fixed small problem * wip * Pseudo interrupt things * Basic prototype operational * correct proc title * Mostly done * Cleanup * cleaner raylet error * Cleaning up a few loose ends * Fixing Race Conds * Prelim testing * Fixing comments and adding second_check for kill * Working_new_impl * demo_ready * Fixing my english * Fixing a few problems * Small problems * Cleaning up * Response to changes * Fixing error passing * Merged to master * fixing lock * Cleaning up print statements * Format * Fixing Unit test build failure * mock_worker fix * java_fix * Canel * Switching to Cancel * Responding to Review * FixFormatting * Lease cancellation * FInal comments? * Moving exist check to CoreWorker * Fix Actor Transport Test * Fixing task manager test * chaning clock repr * Fix build * fix white space * lint fix * Updating to medium size * Fixing Java test compilation issue * lengthen bad timeouts
This commit is contained in:
+22
-1
@@ -1661,12 +1661,33 @@ def kill(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)
|
||||
|
||||
|
||||
def cancel(object_id, force=False):
|
||||
"""Kill a task forcefully.
|
||||
|
||||
This will interrupt any running tasks on the actor, causing them to fail
|
||||
immediately. Any atexit handlers installed in the actor will still be run.
|
||||
|
||||
If this actor is reconstructable, it will be attempted to be reconstructed.
|
||||
|
||||
Args:
|
||||
id (ActorHandle or ObjectID): Handle for the actor to kill or ObjectID
|
||||
of the task to kill.
|
||||
"""
|
||||
worker = ray.worker.global_worker
|
||||
worker.check_connected()
|
||||
|
||||
if not isinstance(object_id, ray.ObjectID):
|
||||
raise TypeError(
|
||||
"ray.cancel() only supported for non-actor object IDs. "
|
||||
"Got: {}.".format(type(object_id)))
|
||||
return worker.core_worker.cancel_task(object_id, force)
|
||||
|
||||
|
||||
def _mode(worker=global_worker):
|
||||
"""This is a wrapper around worker.mode.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user