Skip to content

Instantly share code, notes, and snippets.

@wbbradley
Created October 30, 2015 18:30
Show Gist options
  • Save wbbradley/e91fdc02edfe25c2cf93 to your computer and use it in GitHub Desktop.
Save wbbradley/e91fdc02edfe25c2cf93 to your computer and use it in GitHub Desktop.
Easy async processing in Python
import uuid
from multiprocessing import Pool
def f(u):
print str(u) + ' is a uuid'
if __name__ == '__main__':
pool = Pool(processes=2)
# get some random uuids
uuids = [uuid.uuid4() for x in range(10)]
for u in uuids:
# enqueue a new async task
pool.apply_async(f, [u])
pool.close()
pool.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment