make browser download timeout configurable for blocks and tasks (#3619)
This commit is contained in:
@@ -17,6 +17,7 @@ from skyvern.config import settings
|
||||
from skyvern.constants import (
|
||||
AUTO_COMPLETION_POTENTIAL_VALUES_COUNT,
|
||||
BROWSER_DOWNLOAD_MAX_WAIT_TIME,
|
||||
BROWSER_DOWNLOAD_TIMEOUT,
|
||||
DROPDOWN_MENU_MAX_DISTANCE,
|
||||
REPO_ROOT_DIR,
|
||||
SKYVERN_ID_ATTR,
|
||||
@@ -864,7 +865,7 @@ async def handle_click_to_download_file_action(
|
||||
"Checking if there is any new files after click",
|
||||
download_dir=download_dir,
|
||||
)
|
||||
async with asyncio.timeout(BROWSER_DOWNLOAD_MAX_WAIT_TIME):
|
||||
async with asyncio.timeout(task.download_timeout or BROWSER_DOWNLOAD_MAX_WAIT_TIME):
|
||||
while True:
|
||||
list_files_after = list_files_in_directory(download_dir)
|
||||
if task.browser_session_id:
|
||||
@@ -913,7 +914,9 @@ async def handle_click_to_download_file_action(
|
||||
workflow_run_id=task.workflow_run_id,
|
||||
)
|
||||
try:
|
||||
await wait_for_download_finished(downloading_files=downloading_files)
|
||||
await wait_for_download_finished(
|
||||
downloading_files=downloading_files, timeout=task.download_timeout or BROWSER_DOWNLOAD_TIMEOUT
|
||||
)
|
||||
except DownloadFileMaxWaitingTime as e:
|
||||
LOG.warning(
|
||||
"There're several long-time downloading files, these files might be broken",
|
||||
|
||||
@@ -70,12 +70,14 @@ def set_browser_console_log(browser_context: BrowserContext, browser_artifacts:
|
||||
browser_context.on("console", browser_console_log)
|
||||
|
||||
|
||||
def set_download_file_listener(browser_context: BrowserContext, **kwargs: Any) -> None:
|
||||
def set_download_file_listener(
|
||||
browser_context: BrowserContext, download_timeout: float | None = None, **kwargs: Any
|
||||
) -> None:
|
||||
async def listen_to_download(download: Download) -> None:
|
||||
workflow_run_id = kwargs.get("workflow_run_id")
|
||||
task_id = kwargs.get("task_id")
|
||||
try:
|
||||
async with asyncio.timeout(BROWSER_DOWNLOAD_TIMEOUT):
|
||||
async with asyncio.timeout(download_timeout or BROWSER_DOWNLOAD_TIMEOUT):
|
||||
file_path = await download.path()
|
||||
if file_path.suffix:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user