]> arthur.barton.de Git - netdata.git/commitdiff
Fix occasional crashes in python plugins
authorMagnus Kessler <Magnus.Kessler@gmx.net>
Thu, 27 Oct 2016 09:02:02 +0000 (10:02 +0100)
committerMagnus Kessler <Magnus.Kessler@gmx.net>
Thu, 27 Oct 2016 09:10:45 +0000 (10:10 +0100)
Occasionally python plugins such as the nginx plugin crash with

```
Exception in thread local:
Traceback (most recent call last):
  File "/usr/lib64/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/libexec/netdata/python.d/python_modules/base.py", line 166, in run
    time.sleep(self.timetable['next'] - time.time())
ValueError: sleep length must be non-negative
```

Afterwards no further data is collected for the plugin until netdata
is restarted

python.d/python_modules/base.py

index 70c586f8e411a276b829406cddc75cbcf8a4b7cf..cb04274b8579edf57847e0668dd46d03a7c1382d 100644 (file)
@@ -163,7 +163,7 @@ class SimpleService(threading.Thread):
                 self.error("Something wrong: ", str(e))
                 return
             if status:  # handle retries if update failed
-                time.sleep(self.timetable['next'] - time.time())
+                time.sleep(max (0, self.timetable['next'] - time.time()))
                 self.retries_left = self.retries
             else:
                 self.retries_left -= 1