summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/asyncrpc/client.py
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2023-11-03 08:26:20 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-09 17:33:02 +0000
commit2484bd893189bc24ac210edf2de3b7e1115eebd3 (patch)
treebe9433e53a5bb645816f5b78730830a73bc6ee10 /bitbake/lib/bb/asyncrpc/client.py
parent8f8501ed403dec27acbe780b936bc087fc5006d0 (diff)
downloadpoky-2484bd893189bc24ac210edf2de3b7e1115eebd3.tar.gz
bitbake: hashserv: Add websocket connection implementation
Adds support to the hash equivalence client and server to communicate over websockets. Since websockets are message orientated instead of stream orientated, and new connection class is needed to handle them. Note that websocket support does require the 3rd party websockets python module be installed on the host, but it should not be required unless websockets are actually being used. (Bitbake rev: 56dd2fdbfb6350a9eef43a12aa529c8637887a7e) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/asyncrpc/client.py')
-rw-r--r--bitbake/lib/bb/asyncrpc/client.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/bitbake/lib/bb/asyncrpc/client.py b/bitbake/lib/bb/asyncrpc/client.py
index 7f33099b63..802c07df1f 100644
--- a/bitbake/lib/bb/asyncrpc/client.py
+++ b/bitbake/lib/bb/asyncrpc/client.py
@@ -10,7 +10,7 @@ import json
10import os 10import os
11import socket 11import socket
12import sys 12import sys
13from .connection import StreamConnection, DEFAULT_MAX_CHUNK 13from .connection import StreamConnection, WebsocketConnection, DEFAULT_MAX_CHUNK
14from .exceptions import ConnectionClosedError 14from .exceptions import ConnectionClosedError
15 15
16 16
@@ -47,6 +47,15 @@ class AsyncClient(object):
47 47
48 self._connect_sock = connect_sock 48 self._connect_sock = connect_sock
49 49
50 async def connect_websocket(self, uri):
51 import websockets
52
53 async def connect_sock():
54 websocket = await websockets.connect(uri, ping_interval=None)
55 return WebsocketConnection(websocket, self.timeout)
56
57 self._connect_sock = connect_sock
58
50 async def setup_connection(self): 59 async def setup_connection(self):
51 # Send headers 60 # Send headers
52 await self.socket.send("%s %s" % (self.proto_name, self.proto_version)) 61 await self.socket.send("%s %s" % (self.proto_name, self.proto_version))