import ray ray.init(logging_level="debug") # @ray.remote # class Actor: # def show_namespace(self): # print("namespace: ", ray.get_runtime_context().get_actor_namespace()) # # Create an actor with specified namespace. # actor = Actor.options( # name="my_actor", # namespace="actor_namespace", # <- specify namespace here # lifetime="detached" # ).remote() # ray.get(actor.show_namespace.remote()) # The Output # >>> (Actor pid=30522) namespace: 540bbea1-bc1c-4ec3-8447-a858958151ce import sys import time @ray.remote(max_restarts=1,max_task_retries=1) class A: def __init__(self): print(f'initing') time.sleep(2) def kill(self): sys.exit(-1) def ping(self, msg): return f"hello {msg}" a = A.remote() print(ray.get(a.ping.remote("ok"))) print(a.kill.options(max_task_retries=0).remote()) # raises RayActorError # print(ray.get(a.ping.remote("no retries"))) # raises RayActorError print(ray.get(a.ping.options(max_task_retries=1).remote("task retries"))) # ok # print(ray.get(a.ping.options(max_task_retries=-1).remote("task retries"))) # max_task_retries = 3 raises, = 4 is ok