Vista + Rails 2.0 upgrade => subprocess hangs

E

Eric Promislow

Here's a small Python program I use to grab the output from rake:

=====

from subprocess import Popen, PIPE

p = Popen(args='c:\\ruby\\bin\\ruby.exe c:\\ruby\\bin\\rake -T',
cwd=u'c:\\Users\\ericp\\testing\\file07',
shell=True,
stdin=None,
stderr=PIPE,
stdout=PIPE,
creationflags=0x8000000
);
p.wait()
data = p.stdout.read()
print data

=====

This is on Windows Vista. With Rails 1.2.6 there was no problem.
After
upgrading to Rails 2.0.1, the program now hangs at the call to the
wait()
command. If I manually kill the ruby.exe process, I get some of the
expected
output, but not all of it.

I can run the above command from the command-line with no problem.

The rake code that Ruby loads did change moving from 1.2.6 to 2.0.1,
but
subprocess should run the command to completion.

I'm not sure what happens yet on XP, or other platforms. I'd like to
get this
working on Vista, though. Any ideas.

Thanks,
Eric
 
C

Christian Heimes

Eric said:
Here's a small Python program I use to grab the output from rake:

=====

from subprocess import Popen, PIPE

p = Popen(args='c:\\ruby\\bin\\ruby.exe c:\\ruby\\bin\\rake -T',
cwd=u'c:\\Users\\ericp\\testing\\file07',
shell=True,
stdin=None,
stderr=PIPE,
stdout=PIPE,
creationflags=0x8000000
);
p.wait()
data = p.stdout.read()
print data

Your usage of wait() is dangerous. The code can block indefinitely when
the stdout or stderr buffer is full.

Christian
 
C

Christian Heimes

Eric said:
Here's a small Python program I use to grab the output from rake:

=====

from subprocess import Popen, PIPE

p = Popen(args='c:\\ruby\\bin\\ruby.exe c:\\ruby\\bin\\rake -T',
cwd=u'c:\\Users\\ericp\\testing\\file07',
shell=True,
stdin=None,
stderr=PIPE,
stdout=PIPE,
creationflags=0x8000000
);
p.wait()
data = p.stdout.read()
print data

Your usage of wait() is dangerous. The code can block indefinitely when
the stdout or stderr buffer is full.

Christian
 
E

Eric Promislow

Your usage of wait() is dangerous. The code can block indefinitely when
the stdout or stderr buffer is full.

Christian

That's what it is. `rake -T` returns more data in Rails 2.0.1
than it did in 1.2.6 -- cross-language breakage logically explained.
Thank you, Christian.

- Eric
 
C

Christian Heimes

Eric said:
That's what it is. `rake -T` returns more data in Rails 2.0.1
than it did in 1.2.6 -- cross-language breakage logically explained.
Thank you, Christian.

You can use stdout, stderr = p.communicate() but keep in mind that the
data is buffered in memory. I suggest a temporary file if you expect
more than a couple of MB.

Christian
 
C

Christian Heimes

Eric said:
That's what it is. `rake -T` returns more data in Rails 2.0.1
than it did in 1.2.6 -- cross-language breakage logically explained.
Thank you, Christian.

You can use stdout, stderr = p.communicate() but keep in mind that the
data is buffered in memory. I suggest a temporary file if you expect
more than a couple of MB.

Christian
 

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,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top