from multiprocessing import Pool
import time
def worker(arg):
print("worker for {} started".format(arg))
time.sleep(arg)
print("worker for {} stopped".format(arg))
pool = Pool(4)
results = pool.map(worker, list(range(100)))
pool.close()
pool.join()
ZnJvbSBtdWx0aXByb2Nlc3NpbmcgaW1wb3J0IFBvb2wKaW1wb3J0IHRpbWUKCmRlZiB3b3JrZXIoYXJnKToKICAgIHByaW50KCJ3b3JrZXIgZm9yIHt9IHN0YXJ0ZWQiLmZvcm1hdChhcmcpKQogICAgdGltZS5zbGVlcChhcmcpCiAgICBwcmludCgid29ya2VyIGZvciB7fSBzdG9wcGVkIi5mb3JtYXQoYXJnKSkKICAgIApwb29sID0gUG9vbCg0KQpyZXN1bHRzID0gcG9vbC5tYXAod29ya2VyLCBsaXN0KHJhbmdlKDEwMCkpKQpwb29sLmNsb3NlKCkKcG9vbC5qb2luKCk=