public
Created

  • Download Gist
test.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
import multiprocessing
import time
 
def mytask(num):
print('Started task, sleeping %s' % num)
time.sleep(num)
 
pool = multiprocessing.Pool(4)
jobs = pool.map_async(mytask, [1,2,3,4,5,3,2,3,4,5,2,3,2,3,4,5,6,4], chunksize=1)
pool.close()
 
while True:
if not jobs.ready():
print('We\'re not done yet, %s tasks to go!' % jobs._number_left)
time.sleep(1)
else:
break

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.