Debugging pipe IPC

Jim B. Wilson wilson at afn.org
Mon Dec 17 10:12:59 EST 2007


I have the mother (of all) application(s, written in C++) that 
occasionally outsources certain tasks to a child Python script.  The 
mother fork/execs (or equivalent) the child and then begins serving the 
child's requests.

The child/client sends requests on its stdout and receives responses on 
stdin.  The interaction is facilitated by a Pyrex extension which handles 
the lower-level aspects of the conversation and exposes a few functions 
and classes to the script.

This part works peachy keen, but debugging has so far been via 
print>>stderr-and-scratch-head.

On a contemplative bike ride one day, I imagined how neat it would be to 
run interactively.  On returning, I began to experiment with rebinding 
sys.stdin and sys.stdout to /dev/tty, using the "-i" command-line switch, 
etc. to see if I could devise a child that prompted me with ">>>" and 
allowed me to compose/test small snippets on the terminal.  So far, no 
joy.

Is this possible?  If so, can someone nudge me toward a solution or 
better yet a recipe?

Jim Wilson
Gainesville, FL








More information about the Python-list mailing list