from multiprocessing.pool import ThreadPool as Pool
pool_size = 10
pool = Pool(pool_size)
results = []
for region, directory_ids in direct_dict.iteritems():
for dir in directory_ids:
result = pool.apply_async(describe_with_directory_workspaces,
(region, dir, username))
results.append(result)
for result in results:
code, content = result.get()
if code == 0:
# ...