Debugging pipe IPC
Ian Clark
iclark at mail.ewu.edu
Mon Dec 17 11:55:41 EST 2007
Jim B. Wilson wrote:
> 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
You're looking for the cmd module.
<http://docs.python.org/lib/module-cmd.html>
Ian Clark
More information about the Python-list
mailing list