Ray: Is it possible to signal the ray actor to stop an infinite work?

Created on 1 Jun 2020  路  1Comment  路  Source: ray-project/ray

Dear Experts,
my question looks like weird because I am leveraging ray power to distribute my tasks.
Now, let me clarify my scenario.
I have some actors that are generating some packets for me infinitely.
Something like this:

while True:
         generate()

now I want to put a flag in my actor to be able to signal my actor to stop that.
As I read in documentation, objects are immutable.
Do you think that is my scenario doable?
something like this:

while flag:
         generate()

def stopSignal():
      flag = False

and then from my main function I call that stop

actor.stopSignal.remote()

and it stops

question

Most helpful comment

The problem is that actors run tasks in a blocking fashion - they won't start running the stopSignal until after your infinite loop finishes (which it obviously doesn't). You can address this by concurrently running actor calls with an async actor and then using something like an asyncio Event to tell the main loop to stop.

https://docs.ray.io/en/latest/async_api.html#async-actor

>All comments

The problem is that actors run tasks in a blocking fashion - they won't start running the stopSignal until after your infinite loop finishes (which it obviously doesn't). You can address this by concurrently running actor calls with an async actor and then using something like an asyncio Event to tell the main loop to stop.

https://docs.ray.io/en/latest/async_api.html#async-actor

Was this page helpful?
0 / 5 - 0 ratings

Related issues

WangYiPengPeter picture WangYiPengPeter  路  3Comments

robertnishihara picture robertnishihara  路  3Comments

monocongo picture monocongo  路  3Comments

robertnishihara picture robertnishihara  路  3Comments

timonbimon picture timonbimon  路  3Comments