File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
- from concurrent .futures import ThreadPoolExecutor
1
+ import time
2
+ from concurrent .futures import Future , ThreadPoolExecutor
3
+ from typing import List
2
4
3
5
from tests .e2e .utils import data_fetcher # noqa F401
4
6
5
7
6
8
def execute_lambdas_in_parallel (function_name : str , lambdas_arn : list , arguments : str ):
9
+ def f (function_name , arn , arguments ):
10
+ eval (function_name )(arn , arguments )
11
+
7
12
result_list = []
8
13
with ThreadPoolExecutor () as executor :
9
- running_tasks = executor .map (lambda exec : eval (function_name )(* exec ), [(arn , arguments ) for arn in lambdas_arn ])
14
+ running_tasks : List [Future ] = []
15
+ for arn in lambdas_arn :
16
+ time .sleep (0.5 * len (running_tasks ))
17
+ running_tasks .append (executor .submit (f , function_name , arn , arguments ))
18
+
10
19
executor .shutdown (wait = True )
20
+
11
21
for running_task in running_tasks :
12
- result_list .append (running_task )
22
+ result_list .append (running_task . result () )
13
23
14
24
return result_list
You can’t perform that action at this time.
0 commit comments