Skip to content

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

docs(cloud): validate example timeout setting

MagMueller1359fb22cbce
diff --git a/examples/cloud/01_basic_task.py b/examples/cloud/01_basic_task.py
index 1be9d67f7..ce2054245 100644
--- a/examples/cloud/01_basic_task.py
+++ b/examples/cloud/01_basic_task.py
@@ -2,6 +2,7 @@
import os
import time
+from math import isfinite
from typing import Any
import requests
@@ -14,7 +15,12 @@ API_KEY = os.getenv('BROWSER_USE_API_KEY')
if not API_KEY:
raise RuntimeError('Set BROWSER_USE_API_KEY or add it to .env')
-RUN_TIMEOUT_SECONDS = float(os.getenv('BROWSER_USE_RUN_TIMEOUT', '900'))
+try:
+ RUN_TIMEOUT_SECONDS = float(os.getenv('BROWSER_USE_RUN_TIMEOUT', '900'))
+except ValueError as error:
+ raise RuntimeError('BROWSER_USE_RUN_TIMEOUT must be a positive number of seconds') from error
+if not isfinite(RUN_TIMEOUT_SECONDS) or RUN_TIMEOUT_SECONDS <= 0:
+ raise RuntimeError('BROWSER_USE_RUN_TIMEOUT must be a positive number of seconds')
HEADERS = {'X-Browser-Use-API-Key': API_KEY}
TERMINAL_STATUSES = {'completed', 'failed', 'cancelled'}