Debugging pipe IPC

Ian Clark iclark at mail.ewu.edu
Tue Dec 18 11:21:21 EST 2007


Jim B. Wilson wrote:
> Ian Clark wrote:
>> Jim B. Wilson wrote:
>> ...
>>> The child/client sends requests on its stdout and receives responses 
>>> on stdin.
>> So, why can't you just run this client on the command line and let the 
>> shell handle stdin/stdout for you?
> 
> I'm not sure I understand the topology of your proposal?  And, it's 
> certainly possible the shell has mystical powers of which I am unaware.
> 
> Are you suggesting a run client that spews the mother's messages to the 
> terminal, and I somehow cut/paste them into the client, running with 
> stdin/stdout unconnected to anything but me?  Or is there some 
> combination of tee, etal.,  I can lash together so that my commands (to 
> the client) don't get mixed up with mother's messages?
> 
> Some such arrangement would surely help.  I often forget the ">>stderr," 
> on my scratch-head debugging prints, and mother gets quite upset when 
> the incoming message doesn't fit the mold :)
> 
> Jim

What I'm suggesting is to run the following from the shell: python 
internal_python_program.py. Then you type into the terminal whatever 
'mother' was sending it ("Clean your room!" most like) and see what it 
spits back. If the script is simply reading from stdin and writing to 
stdout there shouldn't be much of a problem. The hardest part might be 
figuring out what 'mother' actually sends it.

If it's very verbose you can type it out once to a file and redirect 
that file to the python process: python internal_python_program.py < 
file_with_mother_commands.txt.

Another idea is to open a file somewhere and write your debug output to 
that. I would also suggest the logging[1] module as well. It's very 
handy for his sort of thing.

Ian

[1] http://docs.python.org/lib/module-logging.html




More information about the Python-list mailing list