xonsh/xontrib/pdb.py

16 lines
407 B
Python
Raw Normal View History

2020-06-05 02:27:19 +02:00
"""Simple built-in debugger. Runs pdb on reception of SIGUSR1 signal."""
import signal
from xonsh.built_ins import XonshSession
2020-06-05 02:27:19 +02:00
def handle_sigusr1(sig, frame):
print("\nSIGUSR1 signal received. Starting interactive debugger...", flush=True)
2022-07-01 21:17:01 +05:30
import pdb # noqa
2020-06-05 02:27:19 +02:00
2022-07-01 21:17:01 +05:30
pdb.Pdb().set_trace(frame) # noqa
2020-06-05 02:27:19 +02:00
def _load_xontrib_(xsh: XonshSession, **_):
signal.signal(signal.SIGUSR1, handle_sigusr1)