A better fix for asyncio test_stdin_broken_pipe (#7221) · python/cpython@ad74d50

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