mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Add timeout for requests
This commit is contained in:
parent
e88fabbe6d
commit
f21d97d5a2
@ -65,7 +65,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
resource = config.get('resource', None)
|
resource = config.get('resource', None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = get(resource)
|
response = get(resource, timeout=10)
|
||||||
except exceptions.MissingSchema:
|
except exceptions.MissingSchema:
|
||||||
_LOGGER.error("Missing resource or schema in configuration. "
|
_LOGGER.error("Missing resource or schema in configuration. "
|
||||||
"Add http:// to your URL.")
|
"Add http:// to your URL.")
|
||||||
@ -141,7 +141,7 @@ class ArestData(object):
|
|||||||
def update(self):
|
def update(self):
|
||||||
""" Gets the latest data from aREST device. """
|
""" Gets the latest data from aREST device. """
|
||||||
try:
|
try:
|
||||||
response = get(self.resource)
|
response = get(self.resource, timeout=10)
|
||||||
if 'error' in self.data:
|
if 'error' in self.data:
|
||||||
del self.data['error']
|
del self.data['error']
|
||||||
self.data = response.json()['variables']
|
self.data = response.json()['variables']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user