jsoncom: gracefully report EMSGSIZE errors
When `jsoncomm` fails because the message is too big it currently does not indicate just how big the message was. This commit adds this information so that it's easier for us to determine what to do about it. We could also include a pointer to `/proc/sys/net/core/wmem_defaults` but it seems we want to not require fiddling with that so let's not do it for now. See also https://github.com/osbuild/osbuild/pull/1838
This commit is contained in:
parent
f4dc0f3f20
commit
29f926f305
2 changed files with 19 additions and 1 deletions
|
|
@ -404,7 +404,13 @@ 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)
|
||||
try:
|
||||
n = self._socket.sendmsg([serialized], cmsg, 0)
|
||||
except OSError as exc:
|
||||
if exc.errno == errno.EMSGSIZE:
|
||||
raise BufferError(
|
||||
f"jsoncomm message size {len(serialized)} is too big") from exc
|
||||
raise exc
|
||||
assert n == len(serialized)
|
||||
|
||||
def send_and_recv(self, payload: object, *, fds: Optional[list] = None):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue