mirror of https://github.com/mahmoud/boltons.git
debugutils docs refresh
This commit is contained in:
parent
aec87c8fd1
commit
99bfce33fd
|
@ -1,18 +1,24 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
"""\
|
|
||||||
A small set of utilities useful for debugging misbehaving applications.
|
|
||||||
"""
|
"""
|
||||||
|
A small set of utilities useful for debugging misbehaving
|
||||||
|
applications. Currently this focuses on ways to use :mod:`pdb`, the
|
||||||
|
built-in Python debugger.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__all__ = ['pdb_on_signal', 'pdb_on_exception']
|
||||||
|
|
||||||
|
|
||||||
def pdb_on_signal(signalnum=None):
|
def pdb_on_signal(signalnum=None):
|
||||||
"""
|
"""Installs a signal handler for *signalnum*, which defaults to
|
||||||
Installs a signal handler for `signalnum` (default SIGINT/keyboard
|
``SIGINT``, or keyboard interrupt/ctrl-c. This signal handler
|
||||||
interrupt/ctrl-c) that launches a pdb breakpoint. This can be
|
launches a :mod:`pdb` breakpoint. Results vary in concurrent
|
||||||
useful for debugging infinite loops and getting into deep call
|
systems, but this technique can be useful for debugging infinite
|
||||||
stacks.
|
loops, or easily getting into deep call stacks.
|
||||||
|
|
||||||
This may have unintended results when used in highly
|
Args:
|
||||||
threaded/concurrent code.
|
signalnum (int): The signal number of the signal to handle
|
||||||
|
with pdb. Defaults to :mod:`signal.SIGINT`, see
|
||||||
|
:mod:`signal` for more information.
|
||||||
"""
|
"""
|
||||||
import pdb
|
import pdb
|
||||||
import signal
|
import signal
|
||||||
|
@ -31,18 +37,23 @@ def pdb_on_signal(signalnum=None):
|
||||||
|
|
||||||
|
|
||||||
def pdb_on_exception(limit=100):
|
def pdb_on_exception(limit=100):
|
||||||
"""
|
"""Installs a handler which, instead of exiting, attaches a
|
||||||
Installs a handler which, instead of exiting, attaches a
|
|
||||||
post-mortem pdb console whenever an unhandled exception is
|
post-mortem pdb console whenever an unhandled exception is
|
||||||
encountered.
|
encountered.
|
||||||
|
|
||||||
To restore default behavior, just do:
|
Args:
|
||||||
|
limit (int): the max number of stack frames to display when
|
||||||
|
printing the traceback
|
||||||
|
|
||||||
`sys.excepthook = sys.__excepthook__`
|
A similar effect can be achieved from the command-line using the
|
||||||
|
following command::
|
||||||
|
|
||||||
A similar effect can be achieved with the following command:
|
python -m pdb your_code.py
|
||||||
|
|
||||||
`python -m pdb your_code.py`
|
But ``pdb_on_exception`` allows you to do this conditionally and within
|
||||||
|
your application. To restore default behavior, just do::
|
||||||
|
|
||||||
|
sys.excepthook = sys.__excepthook__
|
||||||
"""
|
"""
|
||||||
import pdb
|
import pdb
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
``debugutils`` - Debugging utilities
|
``debugutils`` - Debugging utilities
|
||||||
==========
|
====================================
|
||||||
|
|
||||||
.. automodule:: boltons.debugutils
|
.. automodule:: boltons.debugutils
|
||||||
:members:
|
:members:
|
||||||
|
|
Loading…
Reference in New Issue