From 7631999c8f24571b3f22fcaa64f7bf2f1be653fe Mon Sep 17 00:00:00 2001 From: Eric Callahan Date: Fri, 8 Apr 2022 14:37:11 -0400 Subject: [PATCH] klippy_connection: handle credential exceptions Handle exceptions should the attempt to fetch peer credentials on the unix socket fail. This isn't a hard requirement for connection and should not cause the connection to abort. Signed-off-by: Eric Callahan --- moonraker/klippy_connection.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/moonraker/klippy_connection.py b/moonraker/klippy_connection.py index f1fdf01..774a680 100644 --- a/moonraker/klippy_connection.py +++ b/moonraker/klippy_connection.py @@ -232,8 +232,14 @@ class KlippyConnection: "Unable to get Unix Socket, cant fetch peer credentials" ) return - data = sock.getsockopt(socket.SOL_SOCKET, socket.SO_PEERCRED, 12) - pid, uid, gid = struct.unpack("@LLL", data) + try: + data = sock.getsockopt(socket.SOL_SOCKET, socket.SO_PEERCRED, 12) + pid, uid, gid = struct.unpack("@LLL", data) + except asyncio.CancelledError: + raise + except Exception: + logging.exception("Failed to get Klippy Credentials") + return self._peer_cred = { "process_id": pid, "user_id": uid,