Add timeout (fixes #2661) (#2666)

This commit is contained in:
Fabian Affolter 2016-07-30 19:36:56 +02:00 committed by Paulus Schoutsen
parent a94e8f48e0
commit 52a3aa1ca5

View File

@ -95,7 +95,10 @@ class CommandSensorData(object):
_LOGGER.info('Running command: %s', self.command)
try:
return_value = subprocess.check_output(self.command, shell=True)
return_value = subprocess.check_output(self.command, shell=True,
timeout=15)
self.value = return_value.strip().decode('utf-8')
except subprocess.CalledProcessError:
_LOGGER.error('Command failed: %s', self.command)
except subprocess.TimeoutExpired:
_LOGGER.error('Timeout for command: %s', self.command)