Mercurial > hg
annotate contrib/showstack.py @ 26478:a3f7e5461dbd
util.chunkbuffer: special case reading everything
The new code results in simpler logic within the while loop. It is also
faster since we avoid performing operations on the queue and buf
collections. However, there shouldn't be any super hot loops for this
since the whole point of chunkbuffer is to avoid reading large amounts
of data at once. This does, however, make it easier to optimize
chunkbuffer in a subsequent patch.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 05 Oct 2015 16:28:12 -0700 |
parents | bdac264e5ed4 |
children | f2fe7b199bb4 |
rev | line source |
---|---|
26123
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
1 # showstack.py - extension to dump a Python stack trace on signal |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
2 # |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
3 # binds to both SIGQUIT (Ctrl-\) and SIGINFO (Ctrl-T on BSDs) |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
4 |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
5 import sys, signal, traceback |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
6 |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
7 def sigshow(*args): |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
8 sys.stderr.write("\n") |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
9 traceback.print_stack(args[1], limit=10, file=sys.stderr) |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
10 sys.stderr.write("----\n") |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
11 |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
12 def extsetup(ui): |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
13 signal.signal(signal.SIGQUIT, sigshow) |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
14 try: |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
15 signal.signal(signal.SIGINFO, sigshow) |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
16 except AttributeError: |
bdac264e5ed4
contrib: add showstack extension
Matt Mackall <mpm@selenic.com>
parents:
diff
changeset
|
17 pass |