python Concurrent.futures:as_completed到地图

时间:2019-02-05 16:55:10

标签: python concurrency concurrent.futures

我已经并行处理了一些代码,但是需要保留订单作业的提交顺序以及接收顺序

我已经为此花费了很长时间,却一无所获

import concurrent.futures
par_result = []
with concurrent.futures.ProcessPoolExecutor(big_number) as executor:
        future_thing = [executor.submit(fnc, param1, param2,\
                                                      counter) for counter in range(another_number)]
        for future in concurrent.futures.as_completed(future_thing):
            par_result.append(future.result())

import concurrent.futures par_result = [] with concurrent.futures.ProcessPoolExecutor(big_number) as executor: future_thing = [executor.submit(fnc, param1, param2,\ counter) for counter in range(another_number)] for future in concurrent.futures.as_completed(future_thing): par_result.append(future.result())

如何将其重写为类似

with concurrent.futures.ProcessPoolExecutor(big_number) as executor:
        par_results = executor.map(fnc, (param1, param2, counter))
这样就可以执行计数器时间

0 个答案:

没有答案