How remote and get work?

I‘m interested in how the Ray function ‘remote’ and ‘get’ work. There is a demo program.

@ray.remote
def a():
    sleep(1)
    a=some array
    return a

ray.init()
future=[a.remote() for _ in range(3)]
a_list=ray.get(future)
ray.shutdown()

The function ‘a’ will be running when I call remote or running when I call get?

It will be submitted to run after you call remote. But when it will run depends on the current available resources of the system (sometimes it needs to wait for occupied resources to be freed first). But when ray.get returns, it must finish running.

1 Like

Thanks!
If available resources are enough, ray.get will block the program until remote finishes running?

ray.get will, by default, block the program until remote finishes running. But you can provide timeout argument.

1 Like