@@ -673,6 +673,34 @@ async def test_subprocess():
673
673
674
674
loop .run_until_complete (test_subprocess ())
675
675
676
+ def test_communicate_large_stdout_65536 (self ):
677
+ self ._test_communicate_large_stdout (65536 )
678
+
679
+ def test_communicate_large_stdout_65537 (self ):
680
+ self ._test_communicate_large_stdout (65537 )
681
+
682
+ def test_communicate_large_stdout_1000000 (self ):
683
+ self ._test_communicate_large_stdout (1000000 )
684
+
685
+ def _test_communicate_large_stdout (self , size ):
686
+ async def copy_stdin_to_stdout (stdin ):
687
+ # See https://github.com/MagicStack/uvloop/issues/363
688
+ # A program that copies stdin to stdout character by character
689
+ code = ('import sys, shutil; '
690
+ 'shutil.copyfileobj(sys.stdin, sys.stdout, 1)' )
691
+ proc = await asyncio .create_subprocess_exec (
692
+ sys .executable , b'-W' , b'ignore' , b'-c' , code ,
693
+ stdin = asyncio .subprocess .PIPE ,
694
+ stdout = asyncio .subprocess .PIPE ,
695
+ stderr = asyncio .subprocess .PIPE )
696
+ stdout , _stderr = await asyncio .wait_for (proc .communicate (stdin ),
697
+ 60.0 )
698
+ return stdout
699
+
700
+ stdin = b'x' * size
701
+ stdout = self .loop .run_until_complete (copy_stdin_to_stdout (stdin ))
702
+ self .assertEqual (stdout , stdin )
703
+
676
704
def test_write_huge_stdin_8192 (self ):
677
705
self ._test_write_huge_stdin (8192 )
678
706
0 commit comments