Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add signal handler for SIGINT/SIGTERM/Etc #77
Add a standard signal handler for sigint and sigterm, and run a cement_sigint_hook, cement_sigterm_hook, etc within the respective signal. May want to allow the ability to disable this... perhaps with a 'with_signals=False' option to lay_cement/CementApp.
Might make sense just to make a generic cement_signal_hook(app, signum, frame) ... and within the hook one could easily just do a 'if signum == signal.SIGINT:' or ... 'if signum == signal.SIGHUP:'.... etc. rather than a seperate hook for every signal.
Still needs documentation ... but in short CementApp and lay_cement() now support a 'catch_signals' list ... which defaults to:
All signals in the catch_signals list will have a signal handle which raises exc.CementSignalError(signnum, frame) .... therefore one can catch this error for any signal and handle everything from one place. The key point being that becuase you can catch the signal from your 'appmain' then you have the ability to still run app.close() within the 'finally' block...
This is all just so 'app.close()' can be called properly even when a process is killed or whatever. The docs will explain more.