Skip to content

Instantly share code, notes, and snippets.

@xulapp
Created August 27, 2011 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xulapp/1175426 to your computer and use it in GitHub Desktop.
Save xulapp/1175426 to your computer and use it in GitHub Desktop.
parallel
def parallel(tasks):
from threading import Thread
def target(i, task):
results[i] = task()
threads = [Thread(target=target, args=args) for args in enumerate(tasks)]
results = [None] * len(tasks)
for thread in threads:
thread.start()
for thread in threads:
thread.join()
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment