summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/asyncrpc/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/asyncrpc/__init__.py')
-rw-r--r--bitbake/lib/bb/asyncrpc/__init__.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/bitbake/lib/bb/asyncrpc/__init__.py b/bitbake/lib/bb/asyncrpc/__init__.py
new file mode 100644
index 0000000000..b2bec31ab2
--- /dev/null
+++ b/bitbake/lib/bb/asyncrpc/__init__.py
@@ -0,0 +1,31 @@
1#
2# SPDX-License-Identifier: GPL-2.0-only
3#
4
5import itertools
6import json
7
8# The Python async server defaults to a 64K receive buffer, so we hardcode our
9# maximum chunk size. It would be better if the client and server reported to
10# each other what the maximum chunk sizes were, but that will slow down the
11# connection setup with a round trip delay so I'd rather not do that unless it
12# is necessary
13DEFAULT_MAX_CHUNK = 32 * 1024
14
15
16def chunkify(msg, max_chunk):
17 if len(msg) < max_chunk - 1:
18 yield ''.join((msg, "\n"))
19 else:
20 yield ''.join((json.dumps({
21 'chunk-stream': None
22 }), "\n"))
23
24 args = [iter(msg)] * (max_chunk - 1)
25 for m in map(''.join, itertools.zip_longest(*args, fillvalue='')):
26 yield ''.join(itertools.chain(m, "\n"))
27 yield "\n"
28
29
30from .client import AsyncClient, Client
31from .serv import AsyncServer, AsyncServerConnection