[core] Enabling Remote Task Cancelation (#8225)

This commit is contained in:
ijrsvt
2020-05-04 15:24:22 -07:00
committed by GitHub
parent 6c2b9a4cfa
commit cc7bd6650a
9 changed files with 86 additions and 6 deletions
+26
View File
@@ -228,5 +228,31 @@ def test_fast(shutdown_only, use_force):
assert isinstance(e, valid_exceptions(use_force))
@pytest.mark.parametrize("use_force", [True, False])
def test_remote_cancel(ray_start_regular, use_force):
signaler = SignalActor.remote()
@ray.remote
def wait_for(y):
return ray.get(y[0])
@ray.remote
def remote_wait(sg):
return [wait_for.remote([sg[0]])]
sig = signaler.wait.remote()
outer = remote_wait.remote([sig])
inner = ray.get(outer)[0]
with pytest.raises(RayTimeoutError):
ray.get(inner, 1)
ray.cancel(inner)
with pytest.raises(valid_exceptions(use_force)):
ray.get(inner, 10)
if __name__ == "__main__":
sys.exit(pytest.main(["-v", __file__]))
+2 -3
View File
@@ -1679,7 +1679,7 @@ def kill(actor):
def cancel(object_id, force=False):
"""Cancels a locally-submitted task according to the following conditions.
"""Cancels a task according to the following conditions.
If the specified task is pending execution, it will not be executed. If
the task is currently executing, the behavior depends on the ``force``
@@ -1698,8 +1698,7 @@ def cancel(object_id, force=False):
force (boolean): Whether to force-kill a running task by killing
the worker that is running the task.
Raises:
ValueError: This is also raised for actor tasks, already completed
tasks, and non-locally submitted tasks.
TypeError: This is also raised for actor tasks.
"""
worker = ray.worker.global_worker
worker.check_connected()