Permalink
Browse files

Add documentation for set_interrupt_handler

  • Loading branch information...
1 parent 3074c98 commit 6d95acfbc4e23af69060b58c0fa7b18e11062751 @asmeurer asmeurer committed Mar 12, 2013
Showing with 30 additions and 6 deletions.
  1. +14 −4 README.rst
  2. +13 −1 pudb/__init__.py
  3. +3 −1 pudb/debugger.py
View
@@ -48,8 +48,6 @@ Install PuDB using the command::
easy_install pudb
-
-
Getting Started
---------------
@@ -82,13 +80,25 @@ PuDB also has a `mailing list <http://lists.tiker.net/listinfo/pudb>`_ that
you may use to submit patches and requests for help. You can also send a pull
request to the `GitHub repository <https://github.com/inducer/pudb>`_
+Attaching to Running Code
+-------------------------
+
+An alternative to using ``set_trace`` is to use::
+
+ from pudb import set_interrupt_handler; set_interrupt_handler()
+
+at the top of your code. This will set ``SIGINT`` (i.e., ``Ctrl-c``) to
+run ``set_trace``, so that typing ``Ctrl-c`` while your code is running
+will break the code and start debugging. See the docstring of
+``set_interrupt_handler`` for more information.
+
Programming PuDB
----------------
At the programming language level, PuDB displays the same interface
as Python's built-in `pdb module <http://docs.python.org/library/pdb.html>`_.
-Just replace `pdb` with `pudb`.
-(One exception: `run` is called `runstatement`.)
+Just replace ``pdb`` with ``pudb``.
+(One exception: ``run`` is called ``runstatement``.)
License and Dependencies
------------------------
View
@@ -128,7 +128,19 @@ def _interrupt_handler(signum, frame):
def set_interrupt_handler(interrupt_signal=DEFAULT_SIGNAL):
"""
Set up an interrupt handler, to activate PuDB when Python receives the
- signal `interrupt_signal`. By default it is SIGINT (i.e., Control-C).
+ signal `interrupt_signal`. By default it is SIGINT (i.e., Ctrl-c).
+
+ To use a different signal, pass it as the argument to this function, like
+ `set_interrupt_handler(signal.SIGALRM)`. You can then break your code
+ with `kill -ALRM pid`, where `pid` is the process ID of the Python
+ process. Note that PuDB will still use SIGINT once it is running to allow
+ breaking running code. If that is an issue, you can change the default
+ signal by hooking `pudb.DEFAULT_SIGNAL`, like
+
+ >>> import pudb
+ >>> import signal
+ >>> pudb.DEFAULT_SIGNAL = signal.SIGALRM
+
"""
import signal
signal.signal(interrupt_signal, _interrupt_handler)
View
@@ -56,7 +56,7 @@ def newfunc(*fargs, **fkeywords):
m - open module
j/k - up/down
- ctrl-u/d - page up/down
+ Ctrl-u/d - page up/down
h/l - scroll left/right
g/G - start/end
L - show (file/line) location / go to line
@@ -70,6 +70,8 @@ def newfunc(*fargs, **fkeywords):
f1/?/H - show this help screen
q - quit
+ Ctrl-c - when in continue mode, break back to PuDB
+
Side-bar related:
+/- - grow/shrink sidebar

0 comments on commit 6d95acf

Please sign in to comment.