diff options
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) | ||