pytb.rdb module

Remote Debugging

Sometimes you do not have a nice way to control the debugger on the local machine. For example in a jupyter notebook the readline interface is horrible to use.

The debugger is designed to act as a drop-in replacement for the standard pdb debugger. However, when starting a debug session (e.g. using set_trace()) the debugger opens a socket and listens on the specified interface and port for a client.

The client can either be a simple TCP socket tool (like netcat) or the provided RdbClient.

The debugger can be invoked by calling set_trace()

API Documentation

A remote debugging module for the python debugger pdb

class pytb.rdb.RdbClient(host: Optional[str] = None, port: Optional[int] = None)[source]

Bases: object

A simple netcat like socket client that can be used as a convenience wrapper to connect to a remote debugger session.

If host or port are unspecified, they are laoded from the current pytb.config.Config s [rdb] section

pytb.rdb.install_hook() → None[source]

Installs the remote debugger as standard debugging method and calls it when using the builtin breakpoint()

pytb.rdb.set_trace(*args, host: Optional[str] = None, port: Optional[int] = None, patch_stdio: Optional[bool] = None, **kwargs) → None[source]

Opens a remote PDB on the specified host and port if no session is running. If a session is already running (was started previously and a client is still connected) the session is reused instead.

Parameters:patch_stdio – When true, redirects stdout, stderr and stdin to the remote socket.
pytb.rdb.uninstall_hook() → None[source]

Restore the original state of sys.breakpointhook. If install_hook() was never called before, this is a noop