From a537b852e629fe404ae1eaa021163946c0caaf8b Mon Sep 17 00:00:00 2001 From: Micah Yong Date: Sat, 28 Nov 2020 20:36:01 -0800 Subject: [PATCH] [docs][core] Documentation improvement in master/walkthrough.html (#12473) --- doc/source/walkthrough.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/source/walkthrough.rst b/doc/source/walkthrough.rst index b9202be9c..2a4b91716 100644 --- a/doc/source/walkthrough.rst +++ b/doc/source/walkthrough.rst @@ -290,6 +290,13 @@ Cancelling tasks obj_ref = blocking_operation.remote() ray.cancel(obj_ref) + from ray.exceptions import TaskCancelledError + + try: + ray.get(obj_ref) + except TaskCancelledError: + print("Object reference was cancelled.") + .. group-tab:: Java Task cancellation hasn't been implemented in Java yet. @@ -354,7 +361,7 @@ If the current node's object store does not contain the object, the object is do from ray.exceptions import GetTimeoutError @ray.remote - def long_running_function() + def long_running_function(): time.sleep(8) obj_ref = long_running_function.remote() @@ -490,7 +497,7 @@ value. # Call the actor. obj_ref = counter.increment.remote() - ray.get(obj_ref) == 1 + assert ray.get(obj_ref) == 1 .. code-tab:: java