From 52a3aa1ca594a62b512261577f2af5d468472fab Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 30 Jul 2016 19:36:56 +0200 Subject: [PATCH] Add timeout (fixes #2661) (#2666) --- homeassistant/components/sensor/command_line.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/command_line.py b/homeassistant/components/sensor/command_line.py index 3d73017c2e7..eb1fb4603e2 100644 --- a/homeassistant/components/sensor/command_line.py +++ b/homeassistant/components/sensor/command_line.py @@ -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)