Files
poky/bitbake/lib/bb/asyncrpc/__init__.py
Daniel Gomez 22027da10a bitbake: asyncrpc: Fix attribute errors
Export ClientError and ServerError classes from bb.asyncrpc.serv as
required by lib/hashserv/server.py module.

Error:
Client ('192.168.2.184', 51142) connected
Error from client: module 'bb.asyncrpc' has no attribute 'ClientError'
Traceback (most recent call last):
  File "/opt/bbhashserv/lib/bb/asyncrpc/serv.py", line 192, in handle_client
    await client.process_requests()
  File "/opt/bbhashserv/lib/hashserv/server.py", line 200, in process_requests
    await super().process_requests()
  File "/opt/bbhashserv/lib/bb/asyncrpc/serv.py", line 72, in process_requests
    await self.dispatch_message(d)
  File "/opt/bbhashserv/lib/hashserv/server.py", line 217, in dispatch_message
    raise bb.asyncrpc.ClientError("Unrecognized command %r" % msg)
AttributeError: module 'bb.asyncrpc' has no attribute 'ClientError'

(Bitbake rev: 8aca1d341500af8bbe788801c2df3da9bbfacaed)

Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2022-02-17 17:51:03 +00:00

32 lines
951 B
Python

#
# SPDX-License-Identifier: GPL-2.0-only
#
import itertools
import json
# The Python async server defaults to a 64K receive buffer, so we hardcode our
# maximum chunk size. It would be better if the client and server reported to
# each other what the maximum chunk sizes were, but that will slow down the
# connection setup with a round trip delay so I'd rather not do that unless it
# is necessary
DEFAULT_MAX_CHUNK = 32 * 1024
def chunkify(msg, max_chunk):
if len(msg) < max_chunk - 1:
yield ''.join((msg, "\n"))
else:
yield ''.join((json.dumps({
'chunk-stream': None
}), "\n"))
args = [iter(msg)] * (max_chunk - 1)
for m in map(''.join, itertools.zip_longest(*args, fillvalue='')):
yield ''.join(itertools.chain(m, "\n"))
yield "\n"
from .client import AsyncClient, Client
from .serv import AsyncServer, AsyncServerConnection, ClientError, ServerError