8
8
from bnls import BnlsClient
9
9
10
10
11
- def print_result (t ):
12
- r , d = t .result ()
13
- print (f"Results: { r } " )
14
- print (f"Time taken: { d } seconds" )
15
-
16
-
17
11
async def main (args ):
18
12
logging .basicConfig (level = logging .DEBUG )
19
13
@@ -24,25 +18,29 @@ async def main(args):
24
18
seed = args .seed .encode ('ascii' )
25
19
26
20
product = BncsProduct .get (args .product )
21
+
22
+ remote = BnlsClient ()
27
23
local = LocalHashingProvider (args .hashes )
28
- await local .preload ([('IX86' , product .code )], version = args .archive )
29
24
30
- # remote = BnlsClient()
31
- # await remote.connect()
25
+ await asyncio .gather (
26
+ local .preload ([('IX86' , product .code )], version = args .archive ),
27
+ remote .connect ()
28
+ )
32
29
33
30
async def run_test (src , tag ):
34
31
print (f"Starting { tag } test on { product .code } with archive { args .archive } " )
35
32
start = time .perf_counter ()
36
33
result = await src .check_version (product .code , args .archive , seed )
37
34
duration = (time .perf_counter () - start )
38
- return result , duration
35
+ print (f"{ tag } { result } (time: { duration :.3f} s)" )
36
+
37
+ remote_test = asyncio .create_task (run_test (remote , "REMOTE" ))
38
+ local_test = asyncio .create_task (run_test (local , "LOCAL" ))
39
39
40
- task = asyncio .create_task (run_test (local , "LOCAL" ))
41
- task .add_done_callback (print_result )
42
- await task
40
+ await asyncio .gather (remote_test , local_test )
43
41
44
- # remote.disconnect("done")
45
- # await remote.wait_closed()
42
+ remote .disconnect ("done" )
43
+ await remote .wait_closed ()
46
44
47
45
48
46
if __name__ == "__main__" :
0 commit comments