By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

Pythonic tee for subprocess module.

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.