optimize downalod waiting time logic (#1626)
This commit is contained in:
@@ -10,6 +10,7 @@ INPUT_TEXT_TIMEOUT = 120000 # 2 minutes
|
|||||||
PAGE_CONTENT_TIMEOUT = 300 # 5 mins
|
PAGE_CONTENT_TIMEOUT = 300 # 5 mins
|
||||||
BUILDING_ELEMENT_TREE_TIMEOUT_MS = 60 * 1000 # 1 minute
|
BUILDING_ELEMENT_TREE_TIMEOUT_MS = 60 * 1000 # 1 minute
|
||||||
BROWSER_CLOSE_TIMEOUT = 180 # 3 minute
|
BROWSER_CLOSE_TIMEOUT = 180 # 3 minute
|
||||||
|
BROWSER_DOWNLOAD_MAX_WAIT_TIME = 120 # 2 minute
|
||||||
BROWSER_DOWNLOAD_TIMEOUT = 600 # 10 minute
|
BROWSER_DOWNLOAD_TIMEOUT = 600 # 10 minute
|
||||||
DOWNLOAD_FILE_PREFIX = "downloads"
|
DOWNLOAD_FILE_PREFIX = "downloads"
|
||||||
SAVE_DOWNLOADED_FILES_TIMEOUT = 180
|
SAVE_DOWNLOADED_FILES_TIMEOUT = 180
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ from pydantic import BaseModel
|
|||||||
from skyvern.config import settings
|
from skyvern.config import settings
|
||||||
from skyvern.constants import (
|
from skyvern.constants import (
|
||||||
AUTO_COMPLETION_POTENTIAL_VALUES_COUNT,
|
AUTO_COMPLETION_POTENTIAL_VALUES_COUNT,
|
||||||
|
BROWSER_DOWNLOAD_MAX_WAIT_TIME,
|
||||||
BROWSER_DOWNLOAD_TIMEOUT,
|
BROWSER_DOWNLOAD_TIMEOUT,
|
||||||
DROPDOWN_MENU_MAX_DISTANCE,
|
DROPDOWN_MENU_MAX_DISTANCE,
|
||||||
REPO_ROOT_DIR,
|
REPO_ROOT_DIR,
|
||||||
@@ -474,25 +475,23 @@ async def handle_click_to_download_file_action(
|
|||||||
)
|
)
|
||||||
return [ActionFailure(e, download_triggered=False)]
|
return [ActionFailure(e, download_triggered=False)]
|
||||||
|
|
||||||
# wait 5s to start downloading
|
try:
|
||||||
LOG.info(
|
async with asyncio.timeout(BROWSER_DOWNLOAD_MAX_WAIT_TIME):
|
||||||
"Sleep for 5s to let download finish",
|
while True:
|
||||||
task_id=task.task_id,
|
list_files_after = list_files_in_directory(download_dir)
|
||||||
step_id=step.step_id,
|
LOG.info(
|
||||||
workflow_run_id=task.workflow_run_id,
|
"Number of files in download directory after click",
|
||||||
)
|
num_downloaded_files_after=len(list_files_after),
|
||||||
await asyncio.sleep(5)
|
download_dir=download_dir,
|
||||||
list_files_after = list_files_in_directory(download_dir)
|
task_id=task.task_id,
|
||||||
LOG.info(
|
step_id=step.step_id,
|
||||||
"Number of files in download directory after click",
|
workflow_run_id=task.workflow_run_id,
|
||||||
num_downloaded_files_after=len(list_files_after),
|
)
|
||||||
download_dir=download_dir,
|
if len(list_files_after) > len(list_files_before):
|
||||||
task_id=task.task_id,
|
break
|
||||||
step_id=step.step_id,
|
await asyncio.sleep(1)
|
||||||
workflow_run_id=task.workflow_run_id,
|
|
||||||
)
|
|
||||||
|
|
||||||
if len(list_files_after) <= len(list_files_before):
|
except asyncio.TimeoutError:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"No file to download after click",
|
"No file to download after click",
|
||||||
task_id=task.task_id,
|
task_id=task.task_id,
|
||||||
|
|||||||
Reference in New Issue
Block a user