[Tutor] pass argument into running program *outside* of program
Lie Ryan
lie.1296 at gmail.com
Fri Aug 22 19:12:32 CEST 2008
> Message: 8
> Date: Fri, 22 Aug 2008 10:28:44 +0100
> From: "Alan Gauld" <alan.gauld at btinternet.com>
> Subject: Re: [Tutor] pass argument into running program *outside* of
> program
> To: tutor at python.org
> Message-ID: <g8m0sh$l4b$1 at ger.gmane.org>
> Content-Type: text/plain; format=flowed; charset="iso-8859-1";
> reply-type=response
>
>
> "Alan Gauld" <alan.gauld at btinternet.com> wrote
>
> >> $ program.py addMe <username> <var2>
> >
> > create the server with a socket that listens for clients on a port
> > create a client that talks to the socket via that port.
> >
>
> Other options, cruder but arguably simpler, involve
> sharing a database and using one table for input and another
> for output. The server polls the input table and writes output to
> the output table, the clients write requests into the input table
> and read their results out from the output table.
In a much simpler situation, even a communicating from a plain file
could be enough. In the daemon's program folder, there'll be two files:
input and output. You write to input to instruct the server and read the
response from output. This model is in respect to Unix's philosophy:
"make program to handle text streams, because it's the universal
interface".
> This is surprisingly efficient and scaleable, I've had servers
> handling several hundred simultaneous clients using this
> scheme. Its very good where reliability and resiliance are
> important because even if the machine goes dowen the clients
> and servers can restart and pick up where they left off.
>
> Just a thought...
>
> Alan G.
More information about the Tutor
mailing list