Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

tweak timeouts to fail faster

Nick Sweeting18bd8fe7156f
diff --git a/browser_use/browser/session.py b/browser_use/browser/session.py
index eb11e08c6..425f2aa65 100644
--- a/browser_use/browser/session.py
+++ b/browser_use/browser/session.py
@@ -657,11 +657,11 @@ class BrowserSession(BaseModel):
@retry(
wait=2, # wait 2s between each attempt to take a screenshot
retries=2, # try up to 2 times to take the screenshot
- timeout=35, # allow up to 35s for each attempt to take a screenshot
+ timeout=20, # allow up to 20s for each attempt to take a screenshot
semaphore_name='screenshot_global',
semaphore_limit=3, # only 3 concurrent screenshots at a time total on the entire machine (ideally)
semaphore_scope='global', # because it's a hardware VRAM bottleneck, chrome crashes if too many concurrent screenshots are rendered via CDP
- semaphore_timeout=20, # wait up to 20s for a lock
+ semaphore_timeout=10, # wait up to 10s for a lock
semaphore_lax=True, # proceed anyway if we cant get a lock
)
async def _take_screenshot_hybrid(self, page: Page, clip: dict[str, int] | None = None) -> str:
@@ -699,12 +699,12 @@ class BrowserSession(BaseModel):
@retry(
wait=1,
retries=3,
- timeout=30,
+ timeout=10,
semaphore_limit=1,
semaphore_name='playwright_global_object',
semaphore_scope='global',
semaphore_lax=False,
- semaphore_timeout=10, # 10s to wait for global playwright object
+ semaphore_timeout=5, # 5s to wait for global playwright object
)
async def setup_playwright(self) -> None:
"""