[Python-checkins] cpython (3.4): Issue #23243: Fix asyncio._UnixWritePipeTransport.close()

victor.stinner python-checkins at python.org
Thu Jan 15 13:31:20 CET 2015


https://hg.python.org/cpython/rev/2f13d53f4680
changeset:   94167:2f13d53f4680
branch:      3.4
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Jan 15 13:16:50 2015 +0100
summary:
  Issue #23243: Fix asyncio._UnixWritePipeTransport.close()

Do nothing if the transport is already closed. Before it was not possible to
close the transport twice.

files:
  Lib/asyncio/unix_events.py                |  2 +-
  Lib/test/test_asyncio/test_unix_events.py |  3 +++
  2 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -516,7 +516,7 @@
             self._loop.call_soon(self._call_connection_lost, None)
 
     def close(self):
-        if not self._closing:
+        if self._pipe is not None and not self._closing:
             # write_eof is all what we needed to close the write pipe
             self.write_eof()
 
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py
--- a/Lib/test/test_asyncio/test_unix_events.py
+++ b/Lib/test/test_asyncio/test_unix_events.py
@@ -766,6 +766,9 @@
         tr.close()
         tr.write_eof.assert_called_with()
 
+        # closing the transport twice must not fail
+        tr.close()
+
     def test_close_closing(self):
         tr = unix_events._UnixWritePipeTransport(
             self.loop, self.pipe, self.protocol)

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list