我已经并行处理了一些代码,但是需要保留订单作业的提交顺序以及接收顺序
我已经为此花费了很长时间,却一无所获
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))