]> granicus.if.org Git - python/commitdiff
Issue #23243: Fix asyncio._UnixWritePipeTransport.close()
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 15 Jan 2015 12:16:50 +0000 (13:16 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 15 Jan 2015 12:16:50 +0000 (13:16 +0100)
Do nothing if the transport is already closed. Before it was not possible to
close the transport twice.

Lib/asyncio/unix_events.py
Lib/test/test_asyncio/test_unix_events.py

index 14b48438ac910fea50e00545fbe6054e7a6f9593..9f4005cb13a690c77be775669f41af4f2c0b65d9 100644 (file)
@@ -516,7 +516,7 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
             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()
 
index 5f4b024496d860cccce8052c3558fdb875b151f0..4a68ce36b6556a03a51f71337f7b43b4921760fa 100644 (file)
@@ -766,6 +766,9 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
         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)