Get subprocess error output from shell command

Gnarlodious gnarlodious at gmail.com
Sat Apr 2 23:36:27 EDT 2011


OK I get it, and that seems like it should work. But when I simulate a
permissions error by setting the file to unwritable I get an error:
outdata, errdata = process.communicate()
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/Library/Frameworks/Python.framework/Versions/3.1/lib/
python3.1/subprocess.py", line 715, in communicate
 return self._communicate(input)
 File "/Library/Frameworks/Python.framework/Versions/3.1/lib/
python3.1/subprocess.py", line 1191, in _communicate
 stdout, stderr = self._communicate_with_poll(input)
 File "/Library/Frameworks/Python.framework/Versions/3.1/lib/
python3.1/subprocess.py", line 1236, in _communicate_with_poll
 register_and_append(self.stdout, select_POLLIN_POLLPRI)
 File "/Library/Frameworks/Python.framework/Versions/3.1/lib/
python3.1/subprocess.py", line 1223, in register_and_append
 poller.register(file_obj.fileno(), eventmask)
ValueError: I/O operation on closed file
Is there a way to trap the last line and handle it instead of crashing
my webapp?
-- Gnarlie


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /