summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIlya Mashchenko <ilyamaschenko@gmail.com>2019-04-04 11:26:55 +0300
committerGitHub <noreply@github.com>2019-04-04 11:26:55 +0300
commit5e45cb9c2fc7fe27b5d6657bd038286b62c7ea74 (patch)
tree43d5ca53f355ef7974691969c09ecc5f8ae6157e
parent9d320796118d000fb3a8f3097cd02d870823b91a (diff)
python.d.plugin zombie fix (#5797)
##### Summary Fixes: #5491 For some reason i see no `SIGTERM` for second python.d.plugin process on netdata service restart (Centos6). Second process hangs on final `task_queue.task_done()` call (¯\_(ツ)_/¯). This PR adds heartbeat call before final `task_queue.task_done()` call, so the process can exit on SIGPIPE. ##### Component Name [collectors/python.d.plugin](https://github.com/netdata/netdata/blob/master/collectors/python.d.plugin/python.d.plugin.in) ##### Additional Information
-rw-r--r--collectors/python.d.plugin/python.d.plugin.in12
1 files changed, 9 insertions, 3 deletions
diff --git a/collectors/python.d.plugin/python.d.plugin.in b/collectors/python.d.plugin/python.d.plugin.in
index dc6c5be9f8..be211a6e92 100644
--- a/collectors/python.d.plugin/python.d.plugin.in
+++ b/collectors/python.d.plugin/python.d.plugin.in
@@ -131,6 +131,12 @@ JOB_BASE_CONF = {
}
+def heartbeat():
+ if IS_ATTY:
+ return
+ safe_print('\n')
+
+
class HeartBeat(threading.Thread):
def __init__(self, every):
threading.Thread.__init__(self)
@@ -140,9 +146,7 @@ class HeartBeat(threading.Thread):
def run(self):
while True:
time.sleep(self.every)
- if IS_ATTY:
- continue
- safe_print('\n')
+ heartbeat()
def load_module(name):
@@ -201,6 +205,8 @@ class ModuleChecker(multiprocessing.Process):
task = self.task_queue.get()
if task is END_TASK_MARKER:
+ # TODO: find better solution, understand why heartbeat thread doesn't work
+ heartbeat()
self.task_queue.task_done()
self.result_queue.put(END_TASK_MARKER)
return False