INNER CODE UNIT · Python

_read_with_timeout

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

def _read_with_timeout(fd: int, max_bytes: int, timeout_seconds: float) -> bytes | None:
	"""Read up to `max_bytes` from `fd`, blocking up to `timeout_seconds`.

	Returns the bytes read (could be empty if pty hung up), or None on
	timeout. Raises OSError if the fd is closed / EOF (caller treats
	that as the pty exiting).

	Used by the claude_login pty reader loop. We use select() rather
	than non-blocking reads so we can sleep cheaply between chunks
	without burning CPU.
	"""
	import os as _os
	import select

	r, _, _ = select.select([fd], [], [], timeout_seconds)
	if not r:
		return None
	# Could raise OSError if the fd is closed by the time we read.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…