diff options
author | Kiril Vladimiroff <kiril.vladimiroff@cloudsigma.com> | 2014-05-30 14:17:57 +0300 |
---|---|---|
committer | Kiril Vladimiroff <kiril.vladimiroff@cloudsigma.com> | 2014-05-30 14:17:57 +0300 |
commit | 882f7186143c337e0f30f4ed2c0415f238ed5c83 (patch) | |
tree | 7c0bcf4b7c3a748176957563329808242fae6ab2 | |
parent | 2f9b47be819e4aa90d0cfd940557b90cbd6912de (diff) | |
download | vyos-cloud-init-882f7186143c337e0f30f4ed2c0415f238ed5c83.tar.gz vyos-cloud-init-882f7186143c337e0f30f4ed2c0415f238ed5c83.zip |
Add timeouts for reading/writing from/to to the serial console
-rw-r--r-- | cloudinit/cs_utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/cloudinit/cs_utils.py b/cloudinit/cs_utils.py index 4e53c31a..1db3f110 100644 --- a/cloudinit/cs_utils.py +++ b/cloudinit/cs_utils.py @@ -35,6 +35,8 @@ import platform import serial +READ_TIMEOUT = 60 +WRITE_TIMEOUT = 10 SERIAL_PORT = '/dev/ttyS1' if platform.system() == 'Windows': SERIAL_PORT = 'COM2' @@ -76,7 +78,9 @@ class CepkoResult(object): self.result = self._marshal(self.raw_result) def _execute(self): - connection = serial.Serial(SERIAL_PORT) + connection = serial.Serial(port=SERIAL_PORT, + timeout=READ_TIMEOUT, + writeTimeout=WRITE_TIMEOUT) connection.write(self.request) return connection.readline().strip('\x04\n') |