mirror of https://github.com/python/cpython.git
Issue #23243: Fix asyncio._UnixWritePipeTransport.close()
Do nothing if the transport is already closed. Before it was not possible to close the transport twice.
This commit is contained in:
parent
7e222f411c
commit
41ed958ee6
|
@ -516,7 +516,7 @@ def write_eof(self):
|
||||||
self._loop.call_soon(self._call_connection_lost, None)
|
self._loop.call_soon(self._call_connection_lost, None)
|
||||||
|
|
||||||
def close(self):
|
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
|
# write_eof is all what we needed to close the write pipe
|
||||||
self.write_eof()
|
self.write_eof()
|
||||||
|
|
||||||
|
|
|
@ -766,6 +766,9 @@ def test_close(self):
|
||||||
tr.close()
|
tr.close()
|
||||||
tr.write_eof.assert_called_with()
|
tr.write_eof.assert_called_with()
|
||||||
|
|
||||||
|
# closing the transport twice must not fail
|
||||||
|
tr.close()
|
||||||
|
|
||||||
def test_close_closing(self):
|
def test_close_closing(self):
|
||||||
tr = unix_events._UnixWritePipeTransport(
|
tr = unix_events._UnixWritePipeTransport(
|
||||||
self.loop, self.pipe, self.protocol)
|
self.loop, self.pipe, self.protocol)
|
||||||
|
|
Loading…
Reference in New Issue