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.
This commit is contained in:
Christian Kellner 2021-07-08 11:14:01 +00:00 committed by Tom Gundersen
parent 254c1cd9fb
commit 3a69bf39b7

View file

@ -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):
"""