suggestion on a complicated inter-process communication

Paul Boddie paul at boddie.org.uk
Tue Apr 28 11:54:52 EDT 2009


On 28 Apr, 17:40, Way <csw... at gmail.com> wrote:
> Thanks a lot for reply. I understand it is abnormal to implement such
> IPC, while it is worthy for my application.
>
> Well, my process3 and 4 are from an outside application, which both
> need License Check and os.system to involk.

Sounds delightful!

Anyway, looking at your diagram (edited to fit)...

Main
 | \-> P1 -> P3 (from os.system)
 \-> P2 (from os.system) -> P4 (from os.system) ->P5

...if P1, P2 and P4 are able to propagate input and output, then this
is just a matter of having something in the main process which
monitors the input from P5 (via P4 and P2) and which relays the input
to P3 (via P1). This could be as simple as the following:

to_p1.write(from_p2.read())

If this isn't sophisticated enough, because you only want to read some
details from P2, you could either try and read a predetermined amount
from P2, or you could write a communications handler which monitors
the input from P2 using a select.poll object. If the main process is
supposed to be doing other things, then it's quite likely that you'll
have to do something involving either select.poll or threads, anyway.

Paul



More information about the Python-list mailing list