Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import ray
import time
# Start Ray.
def f(x):
return x
# Start 4 tasks in parallel.
result_ids = []
for i in range(4):
# Wait for the tasks to complete and retrieve the results.
# With at least 4 cores, this will take 1 second.
results = ray.get(result_ids) # [0, 1, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment