Do not close fileno if GreenFileIO marked as closed
Fast-and-dirty attempt to fix issue #204
This commit is contained in:
@@ -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',
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user