summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_streams.py
diff options
context:
space:
mode:
authorVincent Michel <vxgmichel@gmail.com>2018-11-08 12:21:47 (GMT)
committerAndrew Svetlov <andrew.svetlov@gmail.com>2018-11-08 12:21:47 (GMT)
commitfd512d76456b65c529a5bc58d8cfe73e4a10de7a (patch)
tree0a3f0c1943f446a886837ea1234021b4e1a9203c /Lib/test/test_asyncio/test_streams.py
parent5d95312fb8eb1684879b9fb8c5c928089326d0df (diff)
downloadcpython-fd512d76456b65c529a5bc58d8cfe73e4a10de7a.zip
cpython-fd512d76456b65c529a5bc58d8cfe73e4a10de7a.tar.gz
cpython-fd512d76456b65c529a5bc58d8cfe73e4a10de7a.tar.bz2
bpo-35065: Remove `StreamReaderProtocol._untrack_reader` (#10212)
The call to `_untrack_reader` is performed too soon, causing the protocol to forget about the reader before `connection_lost` can run and feed the EOF to the reader. See bpo-35065.
Diffstat (limited to 'Lib/test/test_asyncio/test_streams.py')
-rw-r--r--Lib/test/test_asyncio/test_streams.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_streams.py b/Lib/test/test_asyncio/test_streams.py
index 0141df7..043fac7 100644
--- a/Lib/test/test_asyncio/test_streams.py
+++ b/Lib/test/test_asyncio/test_streams.py
@@ -589,6 +589,7 @@ class StreamTests(test_utils.TestCase):
client_writer.write(data)
await client_writer.drain()
client_writer.close()
+ await client_writer.wait_closed()
def start(self):
sock = socket.socket()
@@ -628,6 +629,7 @@ class StreamTests(test_utils.TestCase):
# read it back
msgback = await reader.readline()
writer.close()
+ await writer.wait_closed()
return msgback
messages = []
@@ -666,6 +668,7 @@ class StreamTests(test_utils.TestCase):
client_writer.write(data)
await client_writer.drain()
client_writer.close()
+ await client_writer.wait_closed()
def start(self):
self.server = self.loop.run_until_complete(
@@ -697,6 +700,7 @@ class StreamTests(test_utils.TestCase):
# read it back
msgback = await reader.readline()
writer.close()
+ await writer.wait_closed()
return msgback
messages = []
@@ -987,6 +991,25 @@ os.close(fd)
self.assertEqual(messages, [])
+ def test_eof_feed_when_closing_writer(self):
+ # See http://bugs.python.org/issue35065
+ messages = []
+ self.loop.set_exception_handler(lambda loop, ctx: messages.append(ctx))
+
+ with test_utils.run_test_server() as httpd:
+ rd, wr = self.loop.run_until_complete(
+ asyncio.open_connection(*httpd.address,
+ loop=self.loop))
+
+ f = wr.aclose()
+ self.loop.run_until_complete(f)
+ assert rd.at_eof()
+ f = rd.read()
+ data = self.loop.run_until_complete(f)
+ assert data == b''
+
+ self.assertEqual(messages, [])
+
if __name__ == '__main__':
unittest.main()