Skip to content

Commit ad74d50

Browse files
authored
A better fix for asyncio test_stdin_broken_pipe (#7221)
1 parent 99279ad commit ad74d50

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

‎Lib/test/test_asyncio/test_subprocess.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,10 @@ def prepare_broken_pipe_test(self):
218218

219219
# the program ends before the stdin can be feeded
220220
create = asyncio.create_subprocess_exec(
221-
sys.executable, '-c', 'pass',
221+
sys.executable,
222+
'-c', 'print("hello", flush=True)',
222223
stdin=subprocess.PIPE,
224+
stdout=subprocess.PIPE,
223225
loop=self.loop)
224226
proc = self.loop.run_until_complete(create)
225227
return (proc, large_data)
@@ -228,7 +230,7 @@ def test_stdin_broken_pipe(self):
228230
proc, large_data = self.prepare_broken_pipe_test()
229231

230232
async def write_stdin(proc, data):
231-
await asyncio.sleep(0.5, loop=self.loop)
233+
await proc.stdout.readline()
232234
proc.stdin.write(data)
233235
await proc.stdin.drain()
234236

0 commit comments

Comments
 (0)