sending data to another process's input stream?

Andrew M. Kuchling akuchlin at cnri.reston.va.us
Thu May 20 16:45:28 EDT 1999


Joe Strout writes:
>I have a (C++) program which I would like users to be able to interact
>with via CGI.  But this program has a lot of data in memory, and so I
>need it to keep its state persistent (in memory) between CGI
>invocations.

	The most frequent solution would be to use sockets, whether
Unix or TCP/IP.  Shared memory or message queues would be
alternatives, but they're less rarely used, and Python doesn't even
support them out of the box, yet one rarely sees people asking for
them.  So, you could write a Python program that would be a long-lived
server and accepted connections over a Unix or TCP/IP socket; CGIs
would then talk to the server.  (This is how Zope works, for example.)
Your server could then just act as a front-end for a single
long-running instance of the C++ program, sending output to the
program's standard input.

-- 
A.M. Kuchling			http://starship.python.net/crew/amk/
There are, of course, several things in Ontario that are more dangerous than
wolves. For instance, the step-ladder.
    -- J.W. Curran





More information about the Python-list mailing list