Skip to content

Commit c8701f5

Browse files
gh-158287: Add timeout to test_stopped_child_does_not_block_event_loop
1 parent 3fa40bc commit c8701f5

1 file changed

Lines changed: 16 additions & 15 deletions

File tree

‎Lib/test/test_asyncio/test_subprocess.py‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,21 +1170,22 @@ def test_stopped_child_does_not_block_event_loop(self):
11701170
# must not mistake this for process termination and attempt to reap
11711171
# the child with waitpid(), which blocks the event loop thread.
11721172
async def run():
1173-
proc = await asyncio.create_subprocess_exec(*PROGRAM_BLOCKED)
1174-
try:
1175-
proc.send_signal(signal.SIGSTOP)
1176-
# Verify event loop remains responsive while child is stopped
1177-
for _ in range(3):
1178-
await asyncio.sleep(0.05)
1179-
self.assertIsNone(proc.returncode)
1180-
finally:
1181-
if hasattr(signal, 'SIGCONT'):
1182-
try:
1183-
proc.send_signal(signal.SIGCONT)
1184-
except ProcessLookupError:
1185-
pass
1186-
proc.kill()
1187-
await proc.wait()
1173+
async with asyncio.timeout(support.SHORT_TIMEOUT):
1174+
proc = await asyncio.create_subprocess_exec(*PROGRAM_BLOCKED)
1175+
try:
1176+
proc.send_signal(signal.SIGSTOP)
1177+
# Verify event loop remains responsive while child is stopped
1178+
for _ in range(3):
1179+
await asyncio.sleep(0.05)
1180+
self.assertIsNone(proc.returncode)
1181+
finally:
1182+
if hasattr(signal, 'SIGCONT'):
1183+
try:
1184+
proc.send_signal(signal.SIGCONT)
1185+
except ProcessLookupError:
1186+
pass
1187+
proc.kill()
1188+
await proc.wait()
11881189

11891190
self.loop.run_until_complete(run())
11901191

0 commit comments

Comments
 (0)