Inter-process communication, how? Part 2

Guilherme Polo ggpolo at gmail.com
Sun Dec 23 04:30:39 EST 2007


2007/12/22, ecir.hana at gmail.com <ecir.hana at gmail.com>:
> Hello,
>
> just to recap: last time I asked how to do an interprocess
> communitation, between one Manager process (graphical beckend) and
> some Worker processes.
>
> I decided to go with sockets, thanks for replies, once more.
>
> However, I would like to ask another thing: I would like to collect
> everyting what the Workers print and display in Manager. Or, redirect
> all Workers' stdout to stdio of Manager. If there was only one Worker
> I could use a pipe, right? But if there are more than one Worker, what
> to do? I found something called "named pipe" which seems rather
> complicated.

Named pipe is called FIFO, but they are not that complicated.

> Then I thought I could somehow (how?) create a fake
> (virtual) file object,

That is why it is called named pipe, because you will be using a
(especial) file in your filesystem to use as a pipe.

> redirect stdout of a Worket into it and from
> there send the data to Manager via sockets. Please, what do you think?
>
> Preferably, it should look like this:
>
> --- Worker 1 ---
> ...some code...
> print '123'
>
> --- Manager ---
> Worker 1: 123
>
> --- Worker 2 ---
> ...some code...
> print '456'
>
> --- Manager ---
> Worker 1: 123
> Worker 2: 456
>
> Thanks in advance!
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Manager would create and open the FIFO, Workers would open this same
FIFO. So workers write to FIFO and the manager reads from FIFO.

-- 
-- Guilherme H. Polo Goncalves



More information about the Python-list mailing list