New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add signal handler for SIGINT/SIGTERM/Etc #77

Closed
derks opened this Issue Nov 10, 2011 · 1 comment

Comments

Projects
None yet
1 participant
@derks
Member

derks commented Nov 10, 2011

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.

@ghost ghost assigned derks Dec 16, 2011

derks pushed a commit that referenced this issue Dec 20, 2011

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Dec 20, 2011

Member

Still needs documentation ... but in short CementApp and lay_cement() now support a 'catch_signals[]' list ... which defaults to:

[signal.SIGTERM, signal.SIGINT]

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.

Member

derks commented Dec 20, 2011

Still needs documentation ... but in short CementApp and lay_cement() now support a 'catch_signals[]' list ... which defaults to:

[signal.SIGTERM, signal.SIGINT]

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.

derks pushed a commit that referenced this issue Dec 21, 2011

@derks derks closed this Dec 21, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment