view contrib/showstack.py @ 26455:f2bf76d3d567

demandimport: consolidate code for processing items in fromlist This code was mostly duplicated. An upcoming patch will add more complexity, making the duplication harder to justify. Consolidate the code.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 03 Oct 2015 15:30:17 -0700
parents bdac264e5ed4
children f2fe7b199bb4
line wrap: on
line source

# showstack.py - extension to dump a Python stack trace on signal
#
# binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs)

import sys, signal, traceback

def sigshow(*args):
    sys.stderr.write("\n")
    traceback.print_stack(args[1], limit=10, file=sys.stderr)
    sys.stderr.write("----\n")

def extsetup(ui):
    signal.signal(signal.SIGQUIT, sigshow)
    try:
        signal.signal(signal.SIGINFO, sigshow)
    except AttributeError:
        pass