From 785f84390147b8c63535068a9e7f91f4d84fdfef Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 28 Jul 2020 12:58:57 +0200 Subject: [PATCH] jsoncomm: remove destination from send Now that jsoncomm.Socket is using a connection-oriented socket, the destination in `socket.sendmsg` is ignored and thus can and should be dropped from the `jsoncomm.Socket.send` method. Adjust the tests accordingly. --- osbuild/util/jsoncomm.py | 4 ++-- test/mod/test_util_jsoncomm.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/osbuild/util/jsoncomm.py b/osbuild/util/jsoncomm.py index 06fb5bdf..22d6b6d8 100644 --- a/osbuild/util/jsoncomm.py +++ b/osbuild/util/jsoncomm.py @@ -321,7 +321,7 @@ class Socket(contextlib.AbstractContextManager): return (payload, fdset, msg[3]) - def send(self, payload: object, *, destination: Optional[str] = None, fds: Optional[list] = None): + def send(self, payload: object, *, fds: Optional[list] = None): """Send Message Send a new message via this socket. This operation is synchronous. The @@ -352,5 +352,5 @@ class Socket(contextlib.AbstractContextManager): if fds: cmsg.append((socket.SOL_SOCKET, socket.SCM_RIGHTS, array.array("i", fds))) - n = self._socket.sendmsg([serialized], cmsg, 0, destination) + n = self._socket.sendmsg([serialized], cmsg, 0) assert n == len(serialized) diff --git a/test/mod/test_util_jsoncomm.py b/test/mod/test_util_jsoncomm.py index acb6d30b..99f4d5a2 100644 --- a/test/mod/test_util_jsoncomm.py +++ b/test/mod/test_util_jsoncomm.py @@ -84,7 +84,7 @@ class TestUtilJsonComm(unittest.TestCase): assert msg[0] == data assert len(msg[1]) == 0 - self.server.send(data, destination=msg[2]) + self.server.send(data) msg = self.client.recv() assert msg[0] == data assert len(msg[1]) == 0 @@ -154,7 +154,7 @@ class TestUtilJsonComm(unittest.TestCase): def echo(socket): msg = socket.recv() - socket.send(msg[0], destination=msg[2]) + socket.send(msg[0]) loop.stop() self.client.send({})