From: Peter Warasin Date: Mon, 27 Jun 2011 18:10:51 +0000 (+0200) Subject: collectd_unixsock.py: Fix infinite wait. X-Git-Tag: collectd-4.10.4~10 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=10f561d1ca417bf14c396d7cd169f4f40ec49b81;p=collectd.git collectd_unixsock.py: Fix infinite wait. raise a KeyError if getval() or getthreshold() unixsock returns replies an error because of request of an unknown identifier Signed-off-by: Florian Forster --- diff --git a/contrib/collectd_unixsock.py b/contrib/collectd_unixsock.py index ebe040d6..1b8e6b17 100644 --- a/contrib/collectd_unixsock.py +++ b/contrib/collectd_unixsock.py @@ -68,8 +68,9 @@ class Collectd(): """ numvalues = self._cmd('GETTHRESHOLD "%s"' % identifier) lines = [] - if numvalues: - lines = self._readlines(numvalues) + if not numvalues or numvalues < 0: + raise KeyError("Identifier '%s' not found" % identifier) + lines = self._readlines(numvalues) return lines def getval(self, identifier, flush_after=True): @@ -83,8 +84,9 @@ class Collectd(): """ numvalues = self._cmd('GETVAL "%s"' % identifier) lines = [] - if numvalues: - lines = self._readlines(numvalues) + if not numvalues or numvalues < 0: + raise KeyError("Identifier '%s' not found" % identifier) + lines = self._readlines(numvalues) if flush_after: self.flush(identifiers=[identifier]) return lines