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

'ps -A' command freezes Popen3

P: n/a
Does anybody know why the following lines would freeze python [2.4.1 on
Linux]:

import popen2
a = popen2.Popen3('ps -A')
a.wait()

Thanks

B.

Aug 31 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Am Wed, 31 Aug 2005 07:12:49 -0700 schrieb gao_bolin:
Does anybody know why the following lines would freeze python [2.4.1 on
Linux]:

import popen2
a = popen2.Popen3('ps -A')
a.wait()


Because "ps -A" produces a lot of output to stdout, so that
it blocks. It blocks until you read from the stdout of the subprocess.
If you don't read, it will wait forever. You can redirect the output to a
file "ps -A > /tmp/example". This won't block. Or you use the module
select if you are in a unix environment.

HTH,
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
Aug 31 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.