view contrib/showstack.py @ 30357:5925bda42dbd

bundle2: use compressstream compression engine API Compression engines now have an API for compressing a stream of chunks. Switch to it and make low-level compression code disappear.
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 07 Nov 2016 18:46:37 -0800
parents f2fe7b199bb4
children c9eb92fb87b7
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)

from __future__ import absolute_import
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 extsetup(ui):
    signal.signal(signal.SIGQUIT, sigshow)
    try:
        signal.signal(signal.SIGINFO, sigshow)
    except AttributeError:
        pass