From 3a69bf39b79b8dc8f23122e18136f5b078a90b3d Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Thu, 8 Jul 2021 11:14:01 +0000 Subject: [PATCH] host: catch BrokenPipeError while sending replies Catch the BrokenPipeError exception when sending a reply. This will happen when the other side closes their side of the connection/pipe so in that case we just break out of the serve loop. --- osbuild/host.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/osbuild/host.py b/osbuild/host.py index ea1f5ceb..f9182f52 100644 --- a/osbuild/host.py +++ b/osbuild/host.py @@ -257,7 +257,10 @@ class Service(abc.ABC): _, val, tb = sys.exc_info() reply = self.protocol.encode_exception(val, tb) - self.sock.send(reply, fds=fds) + try: + self.sock.send(reply, fds=fds) + except BrokenPipeError: + break def _handle_message(self, msg, fds): """