make sure status is always set by finally block

confusingly, some errs are not subclasses of Exception (things like sys.exit()). Lets make sure the status is always set so cronitor knows what to ping.
This commit is contained in:
Leo Hemsted
2021-02-01 19:15:37 +00:00
parent 126d810d5a
commit 6a859982d0

View File

@@ -38,13 +38,11 @@ def cronitor(task_name):
@wraps(func)
def inner_decorator(*args, **kwargs):
ping_cronitor('run')
status = 'fail'
try:
ret = func(*args, **kwargs)
status = 'complete'
return ret
except Exception:
status = 'fail'
raise
finally:
ping_cronitor(status)