Commit e0545ee9 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

daemon: Use counter instead of boolean for mainloop abortion

Also log a message when a fatal signal was received and use dict.items.
Signed-off-by: default avatarMichael Hanselmann <>
Reviewed-by: default avatarIustin Pop <>
parent 7345b69b
......@@ -451,10 +451,12 @@ class Mainloop(object):
assert isinstance(signal_handlers, dict) and \
len(signal_handlers) > 0, \
"Broken SignalHandled decorator"
running = True
# Counter for received signals
shutdown_signals = 0
# Start actual main loop
while running:
while shutdown_signals < 1:
if not self.scheduler.empty():
......@@ -464,11 +466,12 @@ class Mainloop(object):
asyncore.loop(count=1, use_poll=True)
# Check whether a signal was raised
for sig in signal_handlers:
handler = signal_handlers[sig]
for (sig, handler) in signal_handlers.items():
if handler.called:
running = sig not in (signal.SIGTERM, signal.SIGINT)
if sig in (signal.SIGTERM, signal.SIGINT):"Received signal %s asking for shutdown", sig)
shutdown_signals += 1
def _CallSignalWaiters(self, signum):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment