Skip to content

bpo-36801: Temporarily fix regression in writer.drain() #13330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Lib/asyncio/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,7 @@ async def drain(self):
# 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')
await sleep(0)
await self._protocol._drain_helper()


Expand Down
23 changes: 0 additions & 23 deletions Lib/test/test_asyncio/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,29 +109,6 @@ def test_open_unix_connection_no_loop_ssl(self):

self._basetest_open_connection_no_loop_ssl(conn_fut)

@unittest.skipIf(ssl is None, 'No ssl module')
def test_drain_on_closed_writer_ssl(self):

async def inner(httpd):
reader, writer = await asyncio.open_connection(
*httpd.address,
ssl=test_utils.dummy_ssl_context())

messages = []
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
writer.write(b'GET / HTTP/1.0\r\n\r\n')
data = await reader.read()
self.assertTrue(data.endswith(b'\r\n\r\nTest message'))

writer.close()
with self.assertRaises(ConnectionResetError):
await writer.drain()

self.assertEqual(messages, [])

with test_utils.run_test_server(use_ssl=True) as httpd:
self.loop.run_until_complete(inner(httpd))

def _basetest_open_connection_error(self, open_connection_fut):
messages = []
self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
Expand Down