From: Victor Stinner Date: Thu, 15 Jan 2015 12:16:50 +0000 (+0100) Subject: Issue #23243: Fix asyncio._UnixWritePipeTransport.close() X-Git-Tag: v3.4.3rc1~129 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41ed958ee6f0ff15836e11013d1cada8c3ae90fc;p=python Issue #23243: Fix asyncio._UnixWritePipeTransport.close() Do nothing if the transport is already closed. Before it was not possible to close the transport twice. --- diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index 14b48438ac..9f4005cb13 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -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() diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 5f4b024496..4a68ce36b6 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -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)