Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

Tipper

Tipper is a small utility for dumping stack tracebacks of running Python processes.

Included is a module that, when imported, installs a signal handler for SIGUSR1. Running kill -SIGUSR1 [pid] will cause the process to dump the current stack trace of each thread to $TMPDIR/tipper-[unix timestamp]-[parent pid]-[pid].log.

If Meliae is installed, information about objects tracked by the garbage collector will be dumped to $TMPDIR/tipper-meliae-[unix timestamp]-[parent pid]-[pid].log.

Tipper can also be used as Django application, though it has no dependencies on Django itself.

For an alternative approach that uses threads instead of signals, see Crier.

Download

Usage

To take Tipper for a test drive, first install Tipper:

$ pip install tipper

Set up a Python process to inspect:

$ cat > test.py <<EOF
> import os, sys, time, tipper
> sys.stdout.write('%s\n' % os.getpid())
> while True:
>     time.sleep(1)
> EOF
$ python test.py
945

And send SIGUSR1 to it:

$ kill -SIGUSR1 945

You should end up with a file in $TMPDIR that looks like the following:

$ cat "$TMPDIR/tipper-1292830152.19-681-945.log"
Date: 2010-12-20 18:29:12.192733
Parent process ID: 681
Process ID: 945

Traceback (thread 140048470763264):

  File "test.py", line 4, in <module>
    time.sleep(1)

      Arguments: <module>()
      Local variables:

      {'__builtins__': <module '__builtin__' (built-in)>,
       '__doc__': None,
       '__file__': 'test.py',
       '__name__': '__main__',
       '__package__': None,
       'os': <module 'os' from '/usr/lib/python2.6/os.pyc'>,
       'sys': <module 'sys' (built-in)>,
       'time': <module 'time' (built-in)>,
       'tipper': <module 'tipper' from '/usr/local/lib/python2.6/dist-packages/tipper/__init__.py'>}

To get a briefer overview of the log, you can use grep:

$ grep -v '^      \|^$' "$TMPDIR/tipper-1292830152.19-681-945.log"
Date: 2010-12-20 18:29:12.192733
Parent process ID: 681
Process ID: 945
Traceback (thread 140048470763264):
  File "test.py", line 4, in <module>
    time.sleep(1)

News

Version 0.1 (Dec. 20, 2010)

  • Initial release.

Development

Download the official development repository using Mercurial:

hg clone https://bitbucket.org/brodie/tipper

Visit Bitbucket if you'd like to fork the project, watch for new changes, or report issues.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.