]> granicus.if.org Git - python/commitdiff
Make asyncio stream sendfile fail on error (was hang) (GH-14025)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 12 Jun 2019 19:10:44 +0000 (12:10 -0700)
committerGitHub <noreply@github.com>
Wed, 12 Jun 2019 19:10:44 +0000 (12:10 -0700)
(cherry picked from commit 0d1942774a70d561dbaaa980742dd0927e8aa51a)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Lib/test/test_asyncio/test_streams.py

index 74e385524dd54bbd7d1595b15afdee37126394a3..a1c62ecee662b3de315d87d0ae232ff308f33164 100644 (file)
@@ -1656,22 +1656,25 @@ os.close(fd)
 
         async def serve_callback(stream):
             data = await stream.readline()
-            self.assertEqual(data, b'begin\n')
+            await stream.write(b'ack-' + data)
             data = await stream.readline()
-            self.assertEqual(data, b'data\n')
+            await stream.write(b'ack-' + data)
             data = await stream.readline()
-            self.assertEqual(data, b'end\n')
-            await stream.write(b'done\n')
+            await stream.write(b'ack-' + data)
             await stream.close()
 
         async def do_connect(host, port):
             stream = await asyncio.connect(host, port)
             await stream.write(b'begin\n')
+            data = await stream.readline()
+            self.assertEqual(b'ack-begin\n', data)
             with open(support.TESTFN, 'rb') as fp:
                 await stream.sendfile(fp)
+            data = await stream.readline()
+            self.assertEqual(b'ack-data\n', data)
             await stream.write(b'end\n')
             data = await stream.readline()
-            self.assertEqual(data, b'done\n')
+            self.assertEqual(data, b'ack-end\n')
             await stream.close()
 
         async def test():