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