From 53b43dc4db7fe5942d959d763a1ba0dfc7f41850 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 10 Sep 2015 21:20:34 +0200 Subject: [PATCH] Add timeout for requests --- homeassistant/components/sensor/swiss_public_transport.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sensor/swiss_public_transport.py b/homeassistant/components/sensor/swiss_public_transport.py index 440c7f8ad28..9f0b90d729f 100644 --- a/homeassistant/components/sensor/swiss_public_transport.py +++ b/homeassistant/components/sensor/swiss_public_transport.py @@ -53,7 +53,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None): try: for location in [config.get('from', None), config.get('to', None)]: # transport.opendata.ch doesn't play nice with requests.Session - result = get(_RESOURCE + 'locations?query=%s' % location) + result = get(_RESOURCE + 'locations?query=%s' % location, + timeout=10) journey.append(result.json()['stations'][0]['name']) except KeyError: _LOGGER.exception( @@ -115,8 +116,8 @@ class PublicTransportData(object): 'from=' + self.start + '&' + 'to=' + self.destination + '&' + 'fields[]=connections/from/departureTimestamp/&' + - 'fields[]=connections/') - + 'fields[]=connections/', + timeout=10) connections = response.json()['connections'][:2] try: