Module: check_mk
Branch: master
Commit: 6301927d1c9bd2e5d4508f2a479f137536aee022
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6301927d1c9bd2…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Jan 18 19:23:48 2017 +0100
livestatus: Fixed exception in case no timeout was set
Change-Id: I378c19333dc8339133dce104897d09b40a80213d
---
livestatus/api/python/livestatus.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/livestatus/api/python/livestatus.py b/livestatus/api/python/livestatus.py
index afcf0dc..45f521a 100644
--- a/livestatus/api/python/livestatus.py
+++ b/livestatus/api/python/livestatus.py
@@ -344,15 +344,19 @@ class BaseConnection:
else:
raise MKLivestatusQueryError("%s: %s" % (code, data.strip()))
- # In case of an IO error or the other side having
- # closed the socket do a reconnect and try again, but
- # only once
except (MKLivestatusSocketClosed, IOError), e:
+ # In case of an IO error or the other side having
+ # closed the socket do a reconnect and try again
self.disconnect()
now = time.time()
if query and (not timeout_at or timeout_at > now):
if timeout_at == None:
- timeout_at = now + self.timeout
+ # Try until timeout reached in case there was a timeout configured.
+ # Otherwise only retry once.
+ timeout_at = now
+ if self.timeout:
+ timeout_at += self.timeout
+
time.sleep(0.1)
self.connect()
self.send_query(query, add_headers)