Module: check_mk
Branch: master
Commit: a788c0f978058ec03fb6fefa0a58a588dde1e4bb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a788c0f978058e…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Thu Jun 28 16:35:31 2018 +0200
Remove finally statement causing PID file to be removed after bail_out call
Change-Id: I9172d90af02c96a11cc6a8bc56298db8535b4e9d
---
cmk/ec/main.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index fcf02ea..69fdd10 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -4029,12 +4029,16 @@ def main():
raise
bail_out(logger, traceback.format_exc())
- finally:
- if cmk.store.have_lock(str(pid_path)):
- try:
- pid_path.unlink()
- except OSError:
- pass
+ # BEWARE: This cleanup shoud *only* run, if bail_out
+ # in the previous except block was *not* executed.
+ # If we use a finally statement here, it *will* execute,
+ # because bail_out's sys.exit(1) statement raises a SystemExit
+ # exception, and Python *would* run this finally-Block.
+ if cmk.store.have_lock(str(pid_path)):
+ try:
+ pid_path.unlink()
+ except OSError:
+ pass
if __name__ == "__main__":