INNER CODE UNIT · Python

_run_with_timeout

browser-use/bux · agent/box_agent.py:192

async def _run_with_timeout(
	proc: asyncio.subprocess.Process,
	timeout: float,
) -> tuple[bytes, bytes] | None:
	"""Wait for `proc` with a timeout; on timeout, terminate (then kill) it.

	asyncio.wait_for cancels the await but does NOT kill the subprocess —
	the child keeps running in the background, holding FDs and pages. Be
	explicit: TERM, give it 2s to exit cleanly, then KILL if still alive,
	then await communicate() so the loop reaps the zombie.

	Returns (stdout, stderr) on success, None on timeout / failure.
	"""
	try:
		return await asyncio.wait_for(proc.communicate(), timeout=timeout)
	except asyncio.TimeoutError:
		try:
			proc.terminate()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…