From c458ee29f28c0d6f843e521bef0411068ce73a6a Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Sun, 15 Jan 2017 17:35:58 +0100 Subject: [PATCH] Rename log message / handle cancellederror on image proxy (#5331) --- homeassistant/components/camera/__init__.py | 14 +++++++++----- homeassistant/components/camera/ffmpeg.py | 2 +- homeassistant/components/camera/mjpeg.py | 2 +- homeassistant/components/camera/synology.py | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/camera/__init__.py b/homeassistant/components/camera/__init__.py index 2d4e73cd6e4..89a2f6c5e46 100644 --- a/homeassistant/components/camera/__init__.py +++ b/homeassistant/components/camera/__init__.py @@ -175,7 +175,7 @@ class Camera(Entity): yield from asyncio.sleep(.5) except asyncio.CancelledError: - _LOGGER.debug("Close stream by browser.") + _LOGGER.debug("Close stream by frontend.") response = None finally: @@ -249,12 +249,16 @@ class CameraImageView(CameraView): @asyncio.coroutine def handle(self, request, camera): """Serve camera image.""" - image = yield from camera.async_camera_image() + try: + image = yield from camera.async_camera_image() - if image is None: - return web.Response(status=500) + if image is None: + return web.Response(status=500) - return web.Response(body=image) + return web.Response(body=image) + + except asyncio.CancelledError: + _LOGGER.debug("Close stream by frontend.") class CameraMjpegStream(CameraView): diff --git a/homeassistant/components/camera/ffmpeg.py b/homeassistant/components/camera/ffmpeg.py index 9c1aaa25f6f..0b8d60ab7f5 100644 --- a/homeassistant/components/camera/ffmpeg.py +++ b/homeassistant/components/camera/ffmpeg.py @@ -86,7 +86,7 @@ class FFmpegCamera(Camera): response.write(data) except asyncio.CancelledError: - _LOGGER.debug("Close stream by browser.") + _LOGGER.debug("Close stream by frontend.") response = None finally: diff --git a/homeassistant/components/camera/mjpeg.py b/homeassistant/components/camera/mjpeg.py index 4bc62d66143..dd030099a45 100644 --- a/homeassistant/components/camera/mjpeg.py +++ b/homeassistant/components/camera/mjpeg.py @@ -125,7 +125,7 @@ class MjpegCamera(Camera): raise HTTPGatewayTimeout() except asyncio.CancelledError: - _LOGGER.debug("Close stream by browser.") + _LOGGER.debug("Close stream by frontend.") response = None finally: diff --git a/homeassistant/components/camera/synology.py b/homeassistant/components/camera/synology.py index d7359c14ded..424e269c555 100644 --- a/homeassistant/components/camera/synology.py +++ b/homeassistant/components/camera/synology.py @@ -277,7 +277,7 @@ class SynologyCamera(Camera): raise HTTPGatewayTimeout() except asyncio.CancelledError: - _LOGGER.debug("Close stream by browser.") + _LOGGER.debug("Close stream by frontend.") response = None finally: