from ray import ray
import sys

ray.connect(sys.argv[1])

@ray.remote
def plus2(x):
    return x + 2

print(ray.get(plus2.remote(4)))

@ray.remote
def fact(x):
    if x <= 0:
        return 1
    return x * ray.get(fact.remote(x - 1))

#print(ray.get(fact.remote(20)))

@ray.remote
def sleeper(x):
    import time
    time.sleep(1)
    return x * 2

holder = []
for i in range(20):
    holder.append(sleeper.remote(i))

print([ray.get(x) for x in holder])

