Interactive remote debugging by redirecting sys.stdin and sys.stdout to a socket or pipe

carl.dhalluin at gmail.com carl.dhalluin at gmail.com
Wed Jul 25 05:30:49 EDT 2007


Hi

I want a simple way to interactively remote debug a running python
script which has no tty terminal attached to it. The scripts are
running standalone (i.e. they are automatically started and have no
terminal) and very infrequently come into error conditions which i
want to understand and debug. The idea is that I do the debugging as
shown below.

Is that a good way of solving my problem? Do I need anything special
for terminal emulation? What type of client should I use? I want
things like tab completion and syntax coloring of ipshell (or similar)
to work.

if <condition>:
    # If I come here I did something wrong. Send an event or email
that the failure has happened
    startRemoteDebugging()

def startRemoteDebugging():
    # open a TCP listen socket and start listening
    # as soon as someone connects to the socket, do authentication
check (e.g. username/pwd)
    # redirect sys.stdin and sys.stdout to the socket
    # start interactive python e.g. ipython ipshellembed()
    # put sys.stdin and sys.stdout back to what they were
    # debugging session is done




More information about the Python-list mailing list