1from multiprocessing.pool import ThreadPool as Pool
2
3pool_size = 10
4pool = Pool(pool_size)
5
6results = []
7
8for region, directory_ids in direct_dict.iteritems():
9 for dir in directory_ids:
10 result = pool.apply_async(describe_with_directory_workspaces,
11 (region, dir, username))
12 results.append(result)
13
14for result in results:
15 code, content = result.get()
16 if code == 0:
17 # ...