def _debug(sig, frame):
d={'<STR_LIT>':frame}         <EOL>d.update(frame.f_globals)  <EOL>d.update(frame.f_locals)<EOL>i = code.InteractiveConsole(d)<EOL>message  = "<STR_LIT>"<EOL>message += '<STR_LIT>'.join(traceback.format_stack(frame))<EOL>i.interact(message)<EOL>
Interrupt running process, and provide a python prompt for
    interactive debugging.

    source: http://stackoverflow.com/questions/132058/showing-the-stack-trace-from-a-running-python-application