imager: catch BrokenPipeError

This commit is contained in:
Romain Bazile 2020-11-12 19:03:20 +01:00
parent 83f45d6c2f
commit 736a09ff5f

View file

@ -99,14 +99,13 @@ class StreamingHandler(http.server.BaseHTTPRequestHandler):
output.condition.wait() output.condition.wait()
frame = output.frame frame = output.frame
self.wfile.write(b"--FRAME\r\n") self.wfile.write(b"--FRAME\r\n")
# TODO exception BrokenPipeError here
self.send_header("Content-Type", "image/jpeg") self.send_header("Content-Type", "image/jpeg")
self.send_header("Content-Length", len(frame)) self.send_header("Content-Length", len(frame))
self.end_headers() self.end_headers()
self.wfile.write(frame) self.wfile.write(frame)
self.wfile.write(b"\r\n") self.wfile.write(b"\r\n")
except Exception as e: except BrokenPipeError as e:
logger.exception(f"Removed streaming client {self.client_address}") logger.info(f"Removed streaming client {self.client_address}")
else: else:
self.send_error(404) self.send_error(404)
self.end_headers() self.end_headers()