diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2024-05-30 09:41:26 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-31 16:56:25 +0100 |
commit | 247d08ae0765fdd73f80e7608f76e36983e2109d (patch) | |
tree | 69c1359556e1235276f10052cf3959c4748fc536 /bitbake/lib/hashserv/client.py | |
parent | f618d1dfd7dd414cb458467d0e35b135d6e7cd32 (diff) | |
download | poky-247d08ae0765fdd73f80e7608f76e36983e2109d.tar.gz |
bitbake: asyncrpc: Remove ClientPool
Batching support on the client side has proven to be a much more
effective way of dealing with server latency than multiple client
connections and is also much nicer on the server, so drop the client
pool support from asyncrpc and the hash server
(Bitbake rev: 6f80560f1c7010d09fe5448fdde616aef8468102)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/hashserv/client.py')
-rw-r--r-- | bitbake/lib/hashserv/client.py | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/bitbake/lib/hashserv/client.py b/bitbake/lib/hashserv/client.py index 775faf935a..d415617b20 100644 --- a/bitbake/lib/hashserv/client.py +++ b/bitbake/lib/hashserv/client.py | |||
@@ -352,83 +352,3 @@ class Client(bb.asyncrpc.Client): | |||
352 | 352 | ||
353 | def _get_async_client(self): | 353 | def _get_async_client(self): |
354 | return AsyncClient(self.username, self.password) | 354 | return AsyncClient(self.username, self.password) |
355 | |||
356 | |||
357 | class ClientPool(bb.asyncrpc.ClientPool): | ||
358 | def __init__( | ||
359 | self, | ||
360 | address, | ||
361 | max_clients, | ||
362 | *, | ||
363 | username=None, | ||
364 | password=None, | ||
365 | become=None, | ||
366 | ): | ||
367 | super().__init__(max_clients) | ||
368 | self.address = address | ||
369 | self.username = username | ||
370 | self.password = password | ||
371 | self.become = become | ||
372 | |||
373 | async def _new_client(self): | ||
374 | client = await create_async_client( | ||
375 | self.address, | ||
376 | username=self.username, | ||
377 | password=self.password, | ||
378 | ) | ||
379 | if self.become: | ||
380 | await client.become_user(self.become) | ||
381 | return client | ||
382 | |||
383 | def _run_key_tasks(self, queries, call): | ||
384 | results = {key: None for key in queries.keys()} | ||
385 | |||
386 | def make_task(key, args): | ||
387 | async def task(client): | ||
388 | nonlocal results | ||
389 | unihash = await call(client, args) | ||
390 | results[key] = unihash | ||
391 | |||
392 | return task | ||
393 | |||
394 | def gen_tasks(): | ||
395 | for key, args in queries.items(): | ||
396 | yield make_task(key, args) | ||
397 | |||
398 | self.run_tasks(gen_tasks()) | ||
399 | return results | ||
400 | |||
401 | def get_unihashes(self, queries): | ||
402 | """ | ||
403 | Query multiple unihashes in parallel. | ||
404 | |||
405 | The queries argument is a dictionary with arbitrary key. The values | ||
406 | must be a tuple of (method, taskhash). | ||
407 | |||
408 | Returns a dictionary with a corresponding key for each input key, and | ||
409 | the value is the queried unihash (which might be none if the query | ||
410 | failed) | ||
411 | """ | ||
412 | |||
413 | async def call(client, args): | ||
414 | method, taskhash = args | ||
415 | return await client.get_unihash(method, taskhash) | ||
416 | |||
417 | return self._run_key_tasks(queries, call) | ||
418 | |||
419 | def unihashes_exist(self, queries): | ||
420 | """ | ||
421 | Query multiple unihash existence checks in parallel. | ||
422 | |||
423 | The queries argument is a dictionary with arbitrary key. The values | ||
424 | must be a unihash. | ||
425 | |||
426 | Returns a dictionary with a corresponding key for each input key, and | ||
427 | the value is True or False if the unihash is known by the server (or | ||
428 | None if there was a failure) | ||
429 | """ | ||
430 | |||
431 | async def call(client, unihash): | ||
432 | return await client.unihash_exists(unihash) | ||
433 | |||
434 | return self._run_key_tasks(queries, call) | ||