summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Sergeyev <vsergeyev@mirantis.com>2015-03-18 11:34:26 +0200
committerVictor Sergeyev <vsergeyev@mirantis.com>2015-03-18 11:43:26 +0200
commit06c450e87225923c3a89860d1777a6f9bad6cbdd (patch)
tree56bce68dc67ff7a175aed850973b4aec9feebc2f
parent84b535becafcdc932ab905061f5fa2fbea35dc74 (diff)
downloadeventlet-06c450e87225923c3a89860d1777a6f9bad6cbdd.tar.gz
Do not close fileno if GreenFileIO marked as closed
Fast-and-dirty attempt to fix issue #204
-rw-r--r--eventlet/greenio/py3.py5
-rw-r--r--tests/subprocess_test.py19
2 files changed, 22 insertions, 2 deletions
diff --git a/eventlet/greenio/py3.py b/eventlet/greenio/py3.py
index e41663a..62208c0 100644
--- a/eventlet/greenio/py3.py
+++ b/eventlet/greenio/py3.py
@@ -126,9 +126,10 @@ class GreenFileIO(_OriginalIOBase):
trampoline(self, write=True)
def close(self):
- _original_os.close(self._fileno)
+ if not self._closed:
+ _original_os.close(self._fileno)
+ self._closed = True
notify_close(self._fileno)
- self._closed = True
for method in [
'fileno', 'flush', 'isatty', 'next', 'read', 'readinto',
'readline', 'readlines', 'seek', 'tell', 'truncate',
diff --git a/tests/subprocess_test.py b/tests/subprocess_test.py
index 2760eac..085f656 100644
--- a/tests/subprocess_test.py
+++ b/tests/subprocess_test.py
@@ -45,3 +45,22 @@ def test_communicate_with_poll():
eventlet.with_timeout(0.1, p.communicate, timeout_value=True)
tdiff = time.time() - t1
assert 0.1 <= tdiff <= 0.2, 'did not stop within allowed time'
+
+
+def test_close_popen_stdin_with_close_fds():
+ p = subprocess.Popen(
+ ['ls'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ close_fds=True,
+ shell=False,
+ cwd=None,
+ env=None)
+
+ p.communicate(None)
+
+ try:
+ p.stdin.close()
+ except Exception as e:
+ assert False, "Exception should not be raised, got %r instead" % e