summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2015-10-19 18:49:30 (GMT)
committerGuido van Rossum <guido@python.org>2015-10-19 18:49:30 (GMT)
commitc44ecdf687897a20f11d0c5212b51e8d31f6100a (patch)
treecd908b285d3249995ae3f34a0ae49cb093203253 /Lib/asyncio
parent2bf91bf46cf5bf9913a126092a8d08bcd7a6157c (diff)
downloadcpython-c44ecdf687897a20f11d0c5212b51e8d31f6100a.zip
cpython-c44ecdf687897a20f11d0c5212b51e8d31f6100a.tar.gz
cpython-c44ecdf687897a20f11d0c5212b51e8d31f6100a.tar.bz2
Issue #25441: asyncio: Raise error from drain() when socket is closed.
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/streams.py9
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()