Skip to content

Commit 2fa9133

Browse files
committed
Adjust janitor main loop to throttle down in case of unexpected Exceptions from
tasks. Thanks for pointing out the issue @Martin-Rehr .
1 parent ec5e11b commit 2fa9133

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sbin/grid_janitor.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@
9090
print("Starting janitor daemon - Ctrl-C to quit")
9191
logger.info("(%s) Starting Janitor daemon" % main_pid)
9292

93+
last_failed = False
9394
logger.debug("(%s) Starting main loop" % main_pid)
9495
print("%s: Start main loop" % os.getpid())
9596
while not check_stop():
9697
try:
9798
now = time.time()
98-
if handle_janitor_tasks(configuration, now) <= 0:
99+
if last_failed:
100+
# Throttle on general exception in main loop
101+
interruptible_sleep(configuration, LONG_THROTTLE_SECS,
102+
(check_run, check_stop))
103+
last_failed = False
104+
elif handle_janitor_tasks(configuration, now) <= 0:
99105
interruptible_sleep(configuration, LONG_THROTTLE_SECS,
100106
(check_run, check_stop))
101107
else:
@@ -108,6 +114,7 @@
108114
# so we make sure to propagate to monitor child
109115
print("Interrupt requested - shutdown")
110116
except Exception as exc:
117+
last_failed = True
111118
logger.error(
112119
"(%s) Caught unexpected exception: %s" % (os.getpid(), exc)
113120
)

0 commit comments

Comments
 (0)