Inter-process communication, how? Part 2
John Nagle
nagle at animats.com
Sun Dec 23 11:45:16 EST 2007
ecir.hana at gmail.com wrote:
> 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. Then I thought I could somehow (how?) create a fake
> (virtual) file object, redirect stdout of a Worket into it and from
> there send the data to Manager via sockets. Please, what do you think?
Take a look at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52296
which does this. I wouldn'd do it quite that way; read the notes
on the article for some criticism. But it's an approach that works.
One can get fancier. I wrote a system under QNX where each
real time process had its text output labeled, timestamped, and transmitted
using QNX interprocess communication to a lower priority logging process
on a different machine. Text output never blocked; if a queue
filled, "..." appeared in the log file. That's a special real-time situation.
John Nagle
More information about the Python-list
mailing list