471,350 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Pythonic tee for subprocess module.

I'd like to use the subprocess module to create a pipeline with a
fork. For example, what if I wanted a "cat" process to send a file to
both an "md5sum" process and a "gzip" process. In bash, I'd do
something like this:
cat source_file | tee >(md5sum source_file.md5sum) | gzip -c source_file.gz
What is the best way to "tee" a Python file object so that I can send
it to two different subprocess.Popen instances? I tried creating a
Tee class with read and write methods that send duplicate data to a
number of file objects, but the Popen class won't accept my class as
an argument to the stdin parameter. subprocess.Popen seems to require
_real_ file objects with file descriptors, etc., not just any class
with a read() and write() method.

Suggestions anyone? Thanks for your help.

--Ethan
Nov 14 '07 #1
0 1094

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by Michael McGarry | last post: by
4 posts views Thread by Nicolas Fleury | last post: by
9 posts views Thread by Daniel Nogradi | last post: by
3 posts views Thread by Darren Dale | last post: by
5 posts views Thread by Grant Edwards | last post: by
3 posts views Thread by Lee | last post: by
12 posts views Thread by bhunter | last post: by
1 post views Thread by Steven Bethard | last post: by
25 posts views Thread by Jeremy Banks | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.