Python Futures" When All"

时间:2017-11-14 20:57:34

标签: python python-2.7

我习惯了C#Task.WhenAll函数。我想知道是否有一个等效的python&concurrent.futures.Future

我正在寻找类似的东西:

pool = concurrent.futures.ThreadPoolExecutor(2)
future1 = pool.submit(lambda : 1 + 1)
future2 = pool.submit(lambda : 1 + 2)

aggregated_future = when_all([future1, future2])
print aggregated_future.result() # print result as a list [2, 3]

0 个答案:

没有答案