Pythonic tee for subprocess module.

J

Joe Blow

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top