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

C

carl.dhalluin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top