mirror of
https://github.com/python/cpython.git
synced 2025-07-10 04:45:36 +00:00
Issue #25441: asyncio: Raise error from drain() when socket is closed.
This commit is contained in:
parent
2bf91bf46c
commit
c44ecdf687
3 changed files with 54 additions and 0 deletions
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue