ability to retry failed job
paulfantom committed
Jun 19, 2016 at 21:57 UTC
ab478fa3fa42910e394fb6f188cc60e0467ba0c5
1 file changed
+6
-5
plugins.d/python.d.plugin
+6
-5
@@ -335,7 +335,8 @@ class PythonCharts(object):
335
"""
336
Tries to execute update() on specified job.
337
This cannot fail thus it is catching every exception.
338
- If job.update() returns False, number of retries is decremented. If there are no more retries, job is stopped.
338
+ If job.update() returns False, number of retries_left is decremented.
339
+ If there are no more retries, job is stopped.
340
Job is also stopped if it throws an exception.
341
This is also updating job run time chart.
342
:param job: object
@@ -350,11 +351,10 @@ class PythonCharts(object):
351
else:
352
since_last = int((t_start - job.timetable['last']) * 1000000)
353
if not job.update(since_last):
353
- if job.retries <= 0:
354
+ if job.retries_left <= 0:
355
self._stop(job, "update failed")
355
- else:
356
- job.retries -= 1
357
- job.timetable['next'] += job.timetable['freq']
356
+ job.retries_left -= 1
357
+ job.timetable['next'] += job.timetable['freq']
358
return
359
except AttributeError:
360
self._stop(job, "no update")
@@ -370,6 +370,7 @@ class PythonCharts(object):
370
sys.stdout.write("END\n")
371
sys.stdout.flush()
372
job.timetable['last'] = t_start
373
+ job.retries_left = job.retries
374
self.first_run = False
375
376
def update(self):