@cryptotaxi247 / netdata-1 / commits / 5e45cb9c2

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

Ilya Mashchenko committed Apr 4, 2019 at 11:26 UTC 5e45cb9c2fc7fe27b5d6657bd038286b62c7ea74
1 file changed +9 -3
collectors/python.d.plugin/python.d.plugin.in
+9 -3
@@ -131,6 +131,12 @@ JOB_BASE_CONF = {
131 }
132
133
134 +def heartbeat():
135 + if IS_ATTY:
136 + return
137 + safe_print('\n')
138 +
139 +
140 class HeartBeat(threading.Thread):
141 def __init__(self, every):
142 threading.Thread.__init__(self)
@@ -140,9 +146,7 @@ class HeartBeat(threading.Thread):
146 def run(self):
147 while True:
148 time.sleep(self.every)
143 - if IS_ATTY:
144 - continue
145 - safe_print('\n')
149 + heartbeat()
150
151
152 def load_module(name):
@@ -201,6 +205,8 @@ class ModuleChecker(multiprocessing.Process):
205 task = self.task_queue.get()
206
207 if task is END_TASK_MARKER:
208 + # TODO: find better solution, understand why heartbeat thread doesn't work
209 + heartbeat()
210 self.task_queue.task_done()
211 self.result_queue.put(END_TASK_MARKER)
212 return False