From 7b5c04c09bca08abe516290229771829fe2a97e4 Mon Sep 17 00:00:00 2001 From: paulfantom Date: Thu, 23 Jun 2016 11:45:32 +0200 Subject: [PATCH] comments --- plugins.d/python.d.plugin | 4 ++++ python.d/python_modules/base.py | 10 ++++++++++ python.d/python_modules/msg.py | 11 ++++------- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/plugins.d/python.d.plugin b/plugins.d/python.d.plugin index a6b41016..b349be94 100755 --- a/plugins.d/python.d.plugin +++ b/plugins.d/python.d.plugin @@ -358,6 +358,10 @@ class PythonCharts(object): self._stop(job, "misbehaving. Reason: " + str(e)) def update(self): + """ + Creates and supervises every job thread. + This will stay forever and ever and ever forever and ever it'll be the one... + """ for job in self.jobs: job.start() diff --git a/python.d/python_modules/base.py b/python.d/python_modules/base.py index 03754da6..b9737fac 100644 --- a/python.d/python_modules/base.py +++ b/python.d/python_modules/base.py @@ -75,6 +75,11 @@ class BaseService(threading.Thread): 'freq': freq} def _run_once(self): + """ + Executes self.update(interval) and draws run time chart. + Return value presents exit status of update() + :return: boolean + """ t_start = time.time() # check if it is time to execute job update() function if self.timetable['next'] > t_start: @@ -103,6 +108,11 @@ class BaseService(threading.Thread): return True def run(self): + """ + Runs job in thread. Handles retries. + Exits when job failed or timed out. + :return: None + """ self.timetable['last'] = time.time() while True: try: diff --git a/python.d/python_modules/msg.py b/python.d/python_modules/msg.py index fbaff211..3f168895 100644 --- a/python.d/python_modules/msg.py +++ b/python.d/python_modules/msg.py @@ -12,14 +12,11 @@ def log_msg(msg_type, *args): Print message on stderr. :param msg_type: str """ - sys.stderr.write(PROGRAM) - sys.stderr.write(" ") - sys.stderr.write(msg_type) - sys.stderr.write(": ") + msg = PROGRAM + " " + str(msg_type) + ":" for i in args: - sys.stderr.write(" ") - sys.stderr.write(str(i)) - sys.stderr.write("\n") + msg += " " + msg += str(i) + sys.stderr.write(msg + "\n") sys.stderr.flush() -- 2.39.2