Skip to content

Commit

Permalink
webshare backbone connection (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykeremy authored May 4, 2024
1 parent d7bca71 commit e75b86c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions skyvern/webeye/browser_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ def __new__(cls) -> BrowserManager:

@staticmethod
async def _create_browser_state(
proxy_location: ProxyLocation | None = None, url: str | None = None, new_context_tree: bool = False
proxy_location: ProxyLocation | None = None,
url: str | None = None,
new_context_tree: bool = False,
task_id: str | None = None,
) -> BrowserState:
pw = await async_playwright().start()
browser_context, browser_artifacts = await BrowserContextFactory.create_browser_context(
pw, proxy_location=proxy_location, url=url
pw,
proxy_location=proxy_location,
url=url,
task_id=task_id,
)
return BrowserState(
pw=pw,
Expand All @@ -57,7 +63,7 @@ async def get_or_create_for_task(self, task: Task) -> BrowserState:
# TODO: percentage (50%) to use new context tree
new_ctx = random.choices([False, True], weights=[0.5, 0.5], k=1)[0]
LOG.info("Creating browser state for task", task_id=task.task_id, new_ctx=new_ctx)
browser_state = await self._create_browser_state(task.proxy_location, task.url, new_ctx)
browser_state = await self._create_browser_state(task.proxy_location, task.url, new_ctx, task.task_id)

# The URL here is only used when creating a new page, and not when using an existing page.
# This will make sure browser_state.page is not None.
Expand Down

0 comments on commit e75b86c

Please sign in to comment.