Passing File Objects into Subprocess.Popen

B

Brandon Harris

I'm running python 2.5 and have bumped into an issue whereby the PIPE
in subprocess.Popen locks up after taking too many characters. I found
some documentation that discuss this problem and offers some ideas for
solutions, the best one being to pass a file object into subprocess
instead of PIPE. This will allow for much larger std output.

http://thraxil.org/users/anders/posts/2008/03/13/Subprocess-Hanging-PIPE-is-your-enemy/

The problem is that, while I can pass in a tempfile.TemporaryFile() and
everything seems to go swimmingly, there doesn't seem to be anything
written to file I handed Popen.

import tempfile
import subprocess

def awesome():
# I understand that not everyone has nuke, but it doesn't seem to
matter what I run through it
# the result is the same.
my_cmd = '/usr/local/Nuke6.0v3/Nuke6.0 -V'

my_stderr = tempfile.TemporaryFile()
my_stdout = tempfile.TemporaryFile()

process = subprocess.Popen(my_cmd, stderr=my_stderr, stdout=my_stdout)
process.wait()

print my_stderr.read()
print my_stdout.read()

print "Finished!!!"

Any help on this issue would be awesome! thanks!

Brandon L. Harris
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top