Skip to content

debug

PDB debugging hook triggered by process signals.

This module installs a signal handler which, upon reception of a configurable signal, enters the Python debugger (pdb) instead of terminating the process.

install_pdb_hook(signum)

Install the pdb hook for a signal.

Parameters:

Name Type Description Default
signum

Signal number or name (e.g. 'USR1') to attach the hook to.

required
Source code in py_misc_utils/debug.py
33
34
35
36
37
38
39
40
41
def install_pdb_hook(signum):
  """Install the pdb hook for a signal.

  Args:
    signum: Signal number or name (e.g. 'USR1') to attach the hook to.
  """
  signum = getattr(signal, signum) if isinstance(signum, str) else signum

  signal.signal(signum, _debug)