Process to process synchronization (unix)
Michael Stenner
mstenner at phy.duke.edu
Tue Mar 19 14:01:19 EST 2002
On Mon, Mar 18, 2002 at 11:16:55AM +0000, Eric Brunel wrote:
> Gillou wrote:
> > I have a Zope application and another running process (in python too).
> > I need to transmit data and signal (hey ! data available, do your job !)
> > in an asynchronous way from the Zope app (in an external method) to the
> > python running process (that runs for another user).
> > The other process waits for the signal, takes given data, does the jobs
> > and waits further signal (...)
> > I'm 99.9% newbie in process to process communication.
> > What packages are helpful for this ?
>
> The two means that come to my mind are:
> - named pipes: quite easy to handle, as they are manipulated just like
> files. The problems are that named pipes are quite difficult to synchronize
> if both processes should send data to the other, and that's it's a
> Unix-only solution. All functions manipulating named pipes are built-ins or
> in module os. If you choose that, I may also provide a few simple examples.
> - sockets: a bit trickier to handle, but far more practical for two-way
> communications and multi-platform. The Python module to handle them is
> simply socket. There's an example in the library reference (see
> http://www.python.org/doc/current/lib/socket-example.html).
It's always seemed to me that named pipes have limited usefulness.
They seem like a bit of a hack that have two major selling points.
1) they are truly persistent in the sense that neither program has to
"set them up" (although _someone_ does... just not for each
instance of the program) and they continue to exist when both
programs are gone.
2) it is REALLY easy to take a program that writes (or reads, but
writes is easier) to a file, and make it write to a named pipe.
The latter is the more persuasive. If you have someone else's program
that writes to a file only, but you want to do something more "active"
with the output, you can make the file a named pipe.
Anyway, other than that, I don't see much going for named pipes.
Sockets are nice because they don't require that you have extra crap
in the filesystem, and they can easily be made network-aware. (Have
the two processes run on two different machines).
Bottom line... I would use sockets.
-Michael
--
Michael Stenner Office Phone: 919-660-2513
Duke University, Dept. of Physics mstenner at phy.duke.edu
Box 90305, Durham N.C. 27708-0305
More information about the Python-list
mailing list