diff options
| author | Guido van Rossum <guido@python.org> | 2015-10-19 18:54:04 (GMT) |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2015-10-19 18:54:04 (GMT) |
| commit | 030f489df7adc389eb0c020e8a7aeda2e727c52f (patch) | |
| tree | 6cf26ed2a07b3f9e5215ae5dd3292ad59fbf0f52 /Lib/asyncio/streams.py | |
| parent | 12a72b06c7eebd6f1d310775c5d3afff142c1058 (diff) | |
| parent | c44ecdf687897a20f11d0c5212b51e8d31f6100a (diff) | |
| download | cpython-030f489df7adc389eb0c020e8a7aeda2e727c52f.zip cpython-030f489df7adc389eb0c020e8a7aeda2e727c52f.tar.gz cpython-030f489df7adc389eb0c020e8a7aeda2e727c52f.tar.bz2 | |
Issue #25441: asyncio: Raise error from drain() when socket is closed. (Merge 3.4->3.5)
Diffstat (limited to 'Lib/asyncio/streams.py')
| -rw-r--r-- | Lib/asyncio/streams.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index bb9fb31..fb786ed 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -301,6 +301,15 @@ class StreamWriter: exc = self._reader.exception() if exc is not None: raise exc + if self._transport is not None: + if self._transport._closing: + # Yield to the event loop so connection_lost() may be + # called. Without this, _drain_helper() would return + # immediately, and code that calls + # write(...); yield from drain() + # in a loop would never call connection_lost(), so it + # would not see an error when the socket is closed. + yield yield from self._protocol._drain_helper() |
