Skip to content

Instantly share code, notes, and snippets.

@bllchmbrs
Last active April 17, 2020 18:00
Show Gist options
  • Save bllchmbrs/60b62279477ee741de32e263b9c7ac67 to your computer and use it in GitHub Desktop.
Save bllchmbrs/60b62279477ee741de32e263b9c7ac67 to your computer and use it in GitHub Desktop.
Running your First Distributed Python Application
import ray
import time
from datetime import datetime as dt
@ray.remote
def adder(input_value):
time.sleep(1)
return input_value+1
if __name__ == '__main__':
ray.init()
values = range(10)
start = dt.now()
new_values = [adder.remote(x) for x in values]
return_value = ray.get(new_values)
end = dt.now()
print("Return Value: {}".format(return_value))
print("Elapsed Time: {}".format((end-start).total_seconds()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment