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
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.
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