From dafbdbd2d028faad0ca0ada3dab24a2ef6b6c50f Mon Sep 17 00:00:00 2001 From: Henrik Nicolaisen Date: Sat, 22 Apr 2017 05:24:21 +0200 Subject: [PATCH] Issue 6749 updated pylgtv to 0.1.6 to fix thread leak in asyncio loop (#7199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * updated pylgtv module to fix problems with timeouts * - update pylgtv to 0.1.6 - handle new TimeoutError exception from pylgtv * used full name for exception handling of concurrent.futures._base.TimeoutError * the exception handling should now follow the rules * float typecasting should not be necessary * use asyncio for TimeoutError it’s an alias for concurrent.futures.TimeoutError --- homeassistant/components/media_player/webostv.py | 12 ++++++++---- homeassistant/components/notify/webostv.py | 2 +- requirements_all.txt | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/media_player/webostv.py b/homeassistant/components/media_player/webostv.py index b8f43486db1..c1b51e2d32a 100644 --- a/homeassistant/components/media_player/webostv.py +++ b/homeassistant/components/media_player/webostv.py @@ -5,6 +5,7 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/media_player.webostv/ """ import logging +import asyncio from datetime import timedelta from urllib.parse import urlparse @@ -24,7 +25,7 @@ from homeassistant.const import ( from homeassistant.loader import get_component import homeassistant.helpers.config_validation as cv -REQUIREMENTS = ['pylgtv==0.1.5', +REQUIREMENTS = ['pylgtv==0.1.6', 'websockets==3.2', 'wakeonlan==0.2.2'] @@ -99,7 +100,8 @@ def setup_tv(host, mac, name, customize, config, hass, add_devices): _LOGGER.warning( "Connected to LG webOS TV %s but not paired", host) return - except (OSError, ConnectionClosed): + except (OSError, ConnectionClosed, TypeError, + asyncio.TimeoutError): _LOGGER.error("Unable to connect to host %s", host) return else: @@ -196,7 +198,8 @@ class LgWebOSDevice(MediaPlayerDevice): app = self._app_list[source['appId']] self._source_list[app['title']] = app - except (OSError, ConnectionClosed): + except (OSError, ConnectionClosed, TypeError, + asyncio.TimeoutError): self._state = STATE_OFF @property @@ -257,7 +260,8 @@ class LgWebOSDevice(MediaPlayerDevice): self._state = STATE_OFF try: self._client.power_off() - except (OSError, ConnectionClosed): + except (OSError, ConnectionClosed, TypeError, + asyncio.TimeoutError): pass def turn_on(self): diff --git a/homeassistant/components/notify/webostv.py b/homeassistant/components/notify/webostv.py index 50788b8cccf..0e91fc8698a 100644 --- a/homeassistant/components/notify/webostv.py +++ b/homeassistant/components/notify/webostv.py @@ -14,7 +14,7 @@ from homeassistant.components.notify import ( ATTR_DATA, BaseNotificationService, PLATFORM_SCHEMA) from homeassistant.const import (CONF_FILENAME, CONF_HOST, CONF_ICON) -REQUIREMENTS = ['pylgtv==0.1.5'] +REQUIREMENTS = ['pylgtv==0.1.6'] _LOGGER = logging.getLogger(__name__) diff --git a/requirements_all.txt b/requirements_all.txt index 7775d07fb63..e98df3bf99b 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -564,7 +564,7 @@ pylast==1.8.0 # homeassistant.components.media_player.webostv # homeassistant.components.notify.webostv -pylgtv==0.1.5 +pylgtv==0.1.6 # homeassistant.components.litejet pylitejet==0.1