I’ve encountered a super puzzling lifecycle/scope(?) issue that took a long time to debug so wanted to share and gather some ideas form the community.
In my project I have a very basic setup (like this) with an actor that I converted into a named one so I don’t need to pass it though multiple layers of my code.
Doing so triggered this bizarre error:
>>> ray.get_actor("CounterActor").read.remote() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "###\envs\ray\lib\site-packages\ray\actor.py", line 111, in remote return self._remote(args, kwargs) File "###\envs\ray\lib\site-packages\ray\actor.py", line 152, in _remote return invocation(args, kwargs) File "###\envs\ray\lib\site-packages\ray\actor.py", line 140, in invocation raise RuntimeError("Lost reference to actor") RuntimeError: Lost reference to actor
I’ve confirmed that my agent is still around because the same one passed via a variable was still happily accepting calls, and even tried to use “detached” lifecycle, just in case, with no effect.
Turned out that as long as I do something like this:
f = ray.get_actor('CounterActor') f.read.remote()
everything works, but converting this to a oneliner doesn’t
so if anyone has ideas on what is going on, I would be happy for any clues