Popen question (redundant processes)

Sebastian sebas0 at gmail.com
Sun Aug 30 15:33:15 EDT 2009


Hello World!
This is my first post on the list and I'm hoping it is the right forum and
not OT, I've searched
a bit on this, but, none-the-wiser!

My question is on the Popen method, here is my snippet:

p1 = Popen(["cat", "georgi_ddr7_allmag_kcor_in_test.dat"], stdout=PIPE )
> p2 = Popen(["fit_coeffs"], stdin=p1.stdout, stdout=PIPE)
> p3 = Popen(["reconstruct_maggies"], stdin=p2.stdout,stdout=PIPE)
> output_maggies_z=p3.communicate()[0]
>
> p1 = Popen(["cat", "georgi_ddr7_allmag_kcor_in_test.dat"], stdout=PIPE )
> p2 = Popen(["fit_coeffs"], stdin=p1.stdout, stdout=PIPE)
> p4 = Popen(["reconstruct_maggies", "--band-shift", "0.1", "--redshift",
> "0."], stdin=p2.stdout,stdout=PIPE)
> output_maggies_z0=p4.communicate()[0]
>
>
That is, p1 and p2 are the same, but p3 and p4 which they are passed to, are
different.
Is there a way to pass p1 and p2 to p3 AND p4 simultaneously, so as to not
need to
run p1 and p2 twice, as above?
What arguments would I need to achieve this?

NOTE: "georgi_ddr7_allmag_kcor_in_test.dat" is a very large file (~1E6
records)

regards,
- Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090830/b59f50b0/attachment.html>


More information about the Python-list mailing list