mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Timeout if Tomato router does not respond for 1 sec
This commit is contained in:
parent
05472481c5
commit
7443a5f963
@ -318,7 +318,7 @@ class TomatoDeviceScanner(object):
|
|||||||
self.logger.info("Tomato:Scanning")
|
self.logger.info("Tomato:Scanning")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = requests.Session().send(self.req)
|
response = requests.Session().send(self.req, timeout=1)
|
||||||
|
|
||||||
# Calling and parsing the Tomato api here. We only need the
|
# Calling and parsing the Tomato api here. We only need the
|
||||||
# wldev and dhcpd_lease values. For API description see:
|
# wldev and dhcpd_lease values. For API description see:
|
||||||
@ -343,7 +343,7 @@ class TomatoDeviceScanner(object):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except requests.ConnectionError:
|
except requests.exceptions.ConnectionError:
|
||||||
# We get this if we could not connect to the router or
|
# We get this if we could not connect to the router or
|
||||||
# an invalid http_id was supplied
|
# an invalid http_id was supplied
|
||||||
self.logger.exception(("Tomato:Failed to connect to the router"
|
self.logger.exception(("Tomato:Failed to connect to the router"
|
||||||
@ -351,6 +351,14 @@ class TomatoDeviceScanner(object):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
# We get this if we could not connect to the router or
|
||||||
|
# an invalid http_id was supplied
|
||||||
|
self.logger.exception(("Tomato:Connection to the router "
|
||||||
|
"timed out"))
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# If json decoder could not parse the response
|
# If json decoder could not parse the response
|
||||||
self.logger.exception(("Tomato:Failed to parse response "
|
self.logger.exception(("Tomato:Failed to parse response "
|
||||||
|
Loading…
x
Reference in New Issue
Block a user