Created
November 16, 2011 20:11
-
-
Save iffy/1371206 to your computer and use it in GitHub Desktop.
broken pipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[matt] /tmp $ python | |
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51) | |
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from subprocess import Popen, PIPE | |
>>> | |
>>> f = open('dafile', 'w') | |
>>> f.write('import sys\n' | |
... 'raise Exception("hey")') | |
>>> f.close() | |
>>> | |
>>> p = Popen(['python', 'dafile'], stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
>>> stdout, stderr = p.communicate('foo') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 691, in communicate | |
return self._communicate(input) | |
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1222, in _communicate | |
bytes_written = os.write(self.stdin.fileno(), chunk) | |
OSError: [Errno 32] Broken pipe | |
>>> | |
[matt] /tmp $ python | |
Python 2.6.6 (r266:84374, Aug 31 2010, 11:00:51) | |
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from subprocess import Popen, PIPE | |
>>> | |
>>> f = open('dafile', 'w') | |
>>> f.write('import sys\n' | |
... 'raise Exception("hey")') | |
>>> f.close() | |
>>> | |
>>> p = Popen(['python', 'dafile'], stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
>>> stdout, stderr = p.communicate('foo') | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 691, in communicate | |
return self._communicate(input) | |
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1222, in _communicate | |
bytes_written = os.write(self.stdin.fileno(), chunk) | |
OSError: [Errno 32] Broken pipe | |
>>> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from subprocess import Popen, PIPE | |
f = open('dafile', 'w') | |
f.write('import sys\n' | |
'raise Exception("hey")') | |
f.close() | |
p = Popen(['python', 'dafile'], stdin=PIPE, stdout=PIPE, stderr=PIPE) | |
stdout, stderr = p.communicate('foo') | |
print 'finished' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python f.py | |
finished | |
[matt] /tmp $ python f.py | |
finished | |
[matt] /tmp $ python f.py | |
finished | |
[matt] /tmp $ python f.py | |
finished | |
[matt] /tmp $ python f.py | |
finished | |
[matt] /tmp $ python f.py | |
finished | |
[matt] /tmp $ python f.py | |
finished |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment