fix pdb_on_signal, add a helpful comment

This commit is contained in:
Mahmoud Hashemi 2014-03-03 20:42:11 -08:00
parent d0ffe8b407
commit c57da7457b
1 changed files with 8 additions and 4 deletions

View File

@ -1,14 +1,18 @@
# -*- coding: utf-8 -*-
def pdb_on_signal(signal=None):
def pdb_on_signal(signalnum=None):
import pdb
import signal
if not signal:
signal = signal.SIGINT
if not signalnum:
signalnum = signal.SIGINT
old_handler = signal.getsignal(signalnum)
def pdb_int_handler(sig, frame):
signal.signal(signalnum, old_handler)
pdb.set_trace()
pdb_on_signal(signalnum) # use 'u' to find your code and 'h' for help
signal.signal(signal.SIGINT, pdb_int_handler)
signal.signal(signalnum, pdb_int_handler)
return