From 8d022898d760e60bb4f87a0227d9f41a11482597 Mon Sep 17 00:00:00 2001 From: Mahmoud Hashemi Date: Sat, 1 Mar 2014 12:51:41 -0800 Subject: [PATCH] my most commonly used signal handler, great for getting at anything that has an infinite loop (intentional or not) --- boltons/debugutils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 boltons/debugutils.py diff --git a/boltons/debugutils.py b/boltons/debugutils.py new file mode 100644 index 0000000..5ac4f0f --- /dev/null +++ b/boltons/debugutils.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + + +def pdb_on_signal(signal=None): + import pdb + import signal + if not signal: + signal = signal.SIGINT + + def pdb_int_handler(sig, frame): + pdb.set_trace() + + signal.signal(signal.SIGINT, pdb_int_handler) + return