Manages browser sessions for different threads.
This class maintains separate browser sessions for different threads, enabling concurrent usage of browsers in multi-threaded environments. Browsers are created lazily only when needed by tools.
Concurrency protection is also implemented. Each browser session is tied
to a specific thread_id and includes protection against concurrent usage.
When a browser is obtained via get_async_browser() or get_sync_browser(),
it is marked as "in use", and subsequent attempts to access the same
browser session will raise a RuntimeError until it is released. In general,
different callers should use different thread_ids to avoid concurrency issues.
BrowserSessionManager(
self,
region: str = 'us-west-2',
)| Name | Type | Description |
|---|---|---|
region | str | Default: 'us-west-2'AWS region for browser client |
| Name | Type |
|---|---|
| region | str |
Get or create an async browser for the specified thread.
Get or create a sync browser for the specified thread.
Release the async browser session for the specified thread.
Release the sync browser session for the specified thread.
Close the async browser session for the specified thread.
Close the sync browser session for the specified thread.
Close all browser sessions.