- Low: It annoys or frustrates me for a moment.
Hi everyone,
I would like to know if it’s possible for an actor to access its own actor handle ?
I am interested in this for a use case where actor A calls a remote function of actor B and would like to pass its own actor handle through this call in order for B to be able to reply to him with another remote function call.
Here is an example where some unknown function “GET_SELF_ACTOR_HANDLE” would do what I am looking for:
@ray.remote
class A:
def f(self, b):
time.sleep(1)
b.g.remote()
@ray.remote
class B:
def __init__(self):
self.x = 0
def f(self, a):
a.f.remote(GET_SELF_ACTOR_HANDLE(self))
self.x = 5
def g(self):
print(self.x)
a = A.remote()
b = B.remote()
b.f.remote(a)
I understand that in this example I can add a “set_own_actor_handle” method like this:
@ray.remote
class A:
def f(self, b):
time.sleep(1)
b.g.remote()
@ray.remote
class B:
def __init__(self):
self.x = 0
def set_own_actor_handle(self, handle):
self.handle = handle
def f(self, a):
a.f.remote(self.handle)
self.x = 5
def g(self):
print(self.x)
a = A.remote()
b = B.remote()
ray.get(b.set_own_actor_handle.remote(b))
b.f.remote(a)
But I would like to know if something more elegant is possible.
Thank you