diff options
| author | Victor Stinner <victor.stinner@gmail.com> | 2019-05-14 22:29:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-05-14 22:29:54 +0200 |
| commit | c647ad9b51c59f71c02cd90c5e67d1b2768323ca (patch) | |
| tree | 615e989e9019d68336f296abd1a4bce24eea68d6 /Lib/asyncio/streams.py | |
| parent | 2fef5b01e36a17e36fd7e65c4b51f5ede8880dda (diff) | |
| download | cpython-git-c647ad9b51c59f71c02cd90c5e67d1b2768323ca.tar.gz | |
Revert "bpo-36801: Fix waiting in StreamWriter.drain for closing SSL transport (GH-13098)" (GH-13328)
This reverts commit 93aa57ac6594d1cc30d147720fc8a7a4e1ca2d3e.
Diffstat (limited to 'Lib/asyncio/streams.py')
| -rw-r--r-- | Lib/asyncio/streams.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index 50badd6b24..d6531f88a7 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -208,9 +208,6 @@ class FlowControlMixin(protocols.Protocol): self._drain_waiter = waiter await waiter - def _get_close_waiter(self, stream): - raise NotImplementedError - class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): """Helper class to adapt between Protocol and StreamReader. @@ -268,9 +265,6 @@ class StreamReaderProtocol(FlowControlMixin, protocols.Protocol): return False return True - def _get_close_waiter(self, stream): - return self._closed - def __del__(self): # Prevent reports about unhandled exceptions. # Better than self._closed._log_traceback = False hack @@ -326,7 +320,7 @@ class StreamWriter: return self._transport.is_closing() async def wait_closed(self): - await self._protocol._get_close_waiter(self) + await self._protocol._closed def get_extra_info(self, name, default=None): return self._transport.get_extra_info(name, default) @@ -344,12 +338,13 @@ class StreamWriter: if exc is not None: raise exc if self._transport.is_closing(): - # Wait for protocol.connection_lost() call - # Raise connection closing error if any, - # ConnectionResetError otherwise - fut = self._protocol._get_close_waiter(self) - await fut - raise ConnectionResetError('Connection lost') + # Yield to the event loop so connection_lost() may be + # called. Without this, _drain_helper() would return + # immediately, and code that calls + # write(...); await drain() + # in a loop would never call connection_lost(), so it + # would not see an error when the socket is closed. + await sleep(0, loop=self._loop) await self._protocol._drain_helper() |
