Python – Trap all signals

As of Python 3.5, the signal constants are defined as an enum, enabling a nicer approach: import signal catchable_sigs = set(signal.Signals) – {signal.SIGKILL, signal.SIGSTOP} for sig in catchable_sigs: signal.signal(sig, print) # Substitute handler of choice for `print`

Where should signal handlers live in a django project?

This was added to the documentation when Django 1.7 was released: Strictly speaking, signal handling and registration code can live anywhere you like, although it’s recommended to avoid the application’s root module and its models module to minimize side-effects of importing code. In practice, signal handlers are usually defined in a signals submodule of the … Read more

Segmentation fault handling

The default action for things like SIGSEGV is to terminate your process but as you’ve installed a handler for it, it’ll call your handler overriding the default behavior. But the problem is segfaulting instruction may be retried after your handler finishes and if you haven’t taken measures to fix the first seg fault, the retried … Read more