summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake-hashclient36
1 files changed, 17 insertions, 19 deletions
diff --git a/bitbake/bin/bitbake-hashclient b/bitbake/bin/bitbake-hashclient
index 3f265e8fa7..a02a65b937 100755
--- a/bitbake/bin/bitbake-hashclient
+++ b/bitbake/bin/bitbake-hashclient
@@ -56,25 +56,24 @@ def main():
56 nonlocal missed_hashes 56 nonlocal missed_hashes
57 nonlocal max_time 57 nonlocal max_time
58 58
59 client = hashserv.create_client(args.address) 59 with hashserv.create_client(args.address) as client:
60 60 for i in range(args.requests):
61 for i in range(args.requests): 61 taskhash = hashlib.sha256()
62 taskhash = hashlib.sha256() 62 taskhash.update(args.taskhash_seed.encode('utf-8'))
63 taskhash.update(args.taskhash_seed.encode('utf-8')) 63 taskhash.update(str(i).encode('utf-8'))
64 taskhash.update(str(i).encode('utf-8'))
65 64
66 start_time = time.perf_counter() 65 start_time = time.perf_counter()
67 l = client.get_unihash(METHOD, taskhash.hexdigest()) 66 l = client.get_unihash(METHOD, taskhash.hexdigest())
68 elapsed = time.perf_counter() - start_time 67 elapsed = time.perf_counter() - start_time
69 68
70 with lock: 69 with lock:
71 if l: 70 if l:
72 found_hashes += 1 71 found_hashes += 1
73 else: 72 else:
74 missed_hashes += 1 73 missed_hashes += 1
75 74
76 max_time = max(elapsed, max_time) 75 max_time = max(elapsed, max_time)
77 pbar.update() 76 pbar.update()
78 77
79 max_time = 0 78 max_time = 0
80 found_hashes = 0 79 found_hashes = 0
@@ -174,9 +173,8 @@ def main():
174 173
175 func = getattr(args, 'func', None) 174 func = getattr(args, 'func', None)
176 if func: 175 if func:
177 client = hashserv.create_client(args.address) 176 with hashserv.create_client(args.address) as client:
178 177 return func(args, client)
179 return func(args, client)
180 178
181 return 0 179 return 0
182 180