suggestion on a complicated inter-process communication

Way cswbww at gmail.com
Tue Apr 28 11:44:32 EDT 2009


Thanks a lot for the reply. I am not familiar with multi-process in
Python. I am now using something like:
A_prog is an os.system to involk Process3
B_prog is an os.system to involk Process4
-------------------------------------------------------
In Main Process:
Process1 = Popen(["A_prog"], stdin=PIPE, stdout=PIPE)
Process2 = Popen(["B_prog"], stdin=PIPE, stdout=PIPE)

cmd = Process2.stdout.readlines()
Process1.stdin.write(cmd)
if Process1.poll():
  Process2.stdin.write("trig from Process1")

-----------------------------------------
In Process5 (another python program):
import sys
sys.stdout.write("process1 argument")
while 1:
    if sys.stdin.readline().strip() == "trig from Process1":
            break
------------------------------------------

However, in this case, Process5's stdout cannot be passed to
MainProcess for Process1, since it has not finished (waiting Process.
1/3 finish).

I am now using Fifos (an external file) to inter-communicate Process1
and 5. But at first run, it compliants "not file found".

Is there any possible solution to make it work? Thank you very much!

On Apr 28, 1:34 am, Aaron Brady <castiro... at gmail.com> wrote:
> On Apr 27, 10:59 pm, Way <csw... at gmail.com> wrote:
>
>
>
> > Hello friends,
>
> > I have a little messy situation on IPC. Please if you can, give me
> > some suggestion on how to implement. Thanks a lot!
>
> > -> denotes create
>
> > MainProcess -> Process1 -> Process3 (from os.system)
> >                    |
> >                     -> Process2 (from os.system) -> Process4 (from
> > os.system) ->Process5
>
> > I would like to make the communication between Process1 and Process5.
> > Process1 needs Process5's output to provide argument to generate
> > Process3, and in turn Process5 needs to wait Process3 finished.
>
> > Thank you very much if you can give a hint.
>
> The 'mmap' module can help with getting the data from 5 to 1.  It
> requires creating a file.  If it's a small amount of data, any old
> file will do.  You may need a socket in order to wait for Process3 to
> join, or write a small '.pyd' or '.so' file that gives you access to
> your system's synchronization object.




More information about the Python-list mailing list