Commits

Brodie Rao committed c061177

Added a more useful example to the README

Comments (0)

Files changed (1)

 
 Set up a Python process to inspect::
 
-    $ python -c "import os, sys, time, tipper
+    $ cat > test.py <<EOF
+    > import os, sys, time, tipper
     > sys.stdout.write('%s\n' % os.getpid())
-    > while 1:
-    >     time.sleep(1)"
-    32345
+    > while True:
+    >     time.sleep(1)
+    > EOF
+    $ python test.py
+    945
 
-And send ``SIGUSR`` to it::
+And send ``SIGUSR1`` to it::
 
-    $ kill -SIGUSR1 32345
+    $ kill -SIGUSR1 945
 
 You should end up with a file in ``$TMPDIR`` that looks like the following::
 
-    $ cat "$TMPDIR/tipper-1292827798.15-681-32345.log"
-    Date: 2010-12-20 17:49:58.152208
+    $ cat "$TMPDIR/tipper-1292830152.19-681-945.log"
+    Date: 2010-12-20 18:29:12.192733
     Parent process ID: 681
-    Process ID: 32345
+    Process ID: 945
 
-    Traceback (thread 140195774322432):
+    Traceback (thread 140048470763264):
 
-      File "<string>", line 4, in <module>
+      File "test.py", line 4, in <module>
+        time.sleep(1)
 
-        Arguments: <module>()
-        Local variables:
+          Arguments: <module>()
+          Local variables:
 
-        {'__builtins__': <module '__builtin__' (built-in)>,
-         '__doc__': None,
-         '__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 'tipper/__init__.py'>}
-
-      File "tipper/__init__.py", line 103, in dump
-        f.write(stack_with_locals(frame))
-
-        Arguments: dump(signum=10, sigframe=<frame object at 0x1408820>)
-        Local variables:
-
-        {'f': <open file '/tmp/tipper-1292827798.15-681-32345.log', mode 'w' at 0x143f6f0>,
-         'fn': 'tipper-1292827798.15-681-32345.log',
-         'frame': <frame object at 0x14f0160>,
-         'frames': {140195774322432: <frame object at 0x14f0160>},
-         'header': 'Date: 2010-12-20 17:49:58.152208\nParent process ID: 681\nProcess ID: 32345\n',
-         'ident': 140195774322432,
-         'pid': 32345,
-         'ppid': 681,
-         'sigframe': <frame object at 0x1408820>,
-         'signum': 10,
-         't': 1292827798.1522081}
+          {'__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-1292827798.15-681-32345.log"
-    Date: 2010-12-20 17:49:12.979945
-    Parent process ID: 14583
-    Process ID: 65990
-    Traceback (thread 140735076650144):
-      File "<string>", line 4, in <module>
-      File "tipper/__init__.py", line 103, in dump
-        f.write(stack_with_locals(frame))
+    $ 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)