p = multiprocessing.Pool()
for result in p.imap_unordered(f, args, chunksize=1):
    pass
p.close()
p.join()
if __name__ == '__main__':
    main()
Python multiprocessing: how to limit the number of waiting processes?