view contrib/showstack.py @ 41204:e3cfe0702eac

revlog: inline opener options logic into _loadindex() We always call _loadindex() during __init__. But we also call _loadindex() as part of censorrevision(). Before, when reloading the index during censorrevision(), we would lose the configured mmapindexthreshold setting from the opener. By inlining the logic in _loadindex(), we ensure that opener options are always respected when loading the index. Differential Revision: https://phab.mercurial-scm.org/D5563
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 09 Jan 2019 16:18:00 -0800
parents acf5dbe39478
children 6dae1f31c6c9
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)
"""dump stack trace when receiving SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs)
"""

from __future__ import absolute_import, print_function
import signal
import sys
import traceback

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

def sigexit(*args):
    sigshow(*args)
    print('alarm!')
    sys.exit(1)

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