Skip to content

Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.

feat: add MINERU_TASK_RESULT_DOWNLOAD_TIMEOUT_SECONDS for configurable task result download timeout

myhlolia812c0236c40
diff --git a/docs/en/usage/cli_tools.md b/docs/en/usage/cli_tools.md
index dc394f87..b842a621 100644
--- a/docs/en/usage/cli_tools.md
+++ b/docs/en/usage/cli_tools.md
@@ -147,6 +147,16 @@ Here are the environment variables and their descriptions:
* Default is `300` seconds.
* Applies to temporary local API startup in `mineru`, preload startup in `mineru-gradio`, and router-managed local workers.
+- `MINERU_TASK_RESULT_TIMEOUT_SECONDS`:
+ * Used to control how long clients wait for a task to complete and reach a terminal state.
+ * Default is `3600` seconds, and the value must be greater than or equal to `1`.
+ * Applies to task-status polling in `mineru`, `mineru-gradio`, `mineru-router`, and other API-client scenarios.
+
+- `MINERU_TASK_RESULT_DOWNLOAD_TIMEOUT_SECONDS`:
+ * Used to control the read timeout when retrieving completed task results, including waiting for server-side ZIP generation and downloading the result ZIP.
+ * Default is `600` seconds, and the value must be greater than or equal to `1`.
+ * This is not a hard limit for total download duration; if the server keeps returning data, the total download time may exceed this value.
+
- `MINERU_API_TASK_RETENTION_SECONDS`:
* Used to set how long completed or failed tasks are retained, in seconds.
* Default is `86400` seconds (24 hours).
diff --git a/docs/zh/usage/cli_tools.md b/docs/zh/usage/cli_tools.md
index 885637f7..22e87d78 100644
--- a/docs/zh/usage/cli_tools.md
+++ b/docs/zh/usage/cli_tools.md
@@ -141,6 +141,16 @@ MinerU命令行工具的某些参数存在相同功能的环境变量配置,
* 默认为 `300` 秒。
* 适用于 `mineru` 的临时本地 API、`mineru-gradio` 的 preload 启动,以及 `mineru-router` 托管的本地 worker。
+- `MINERU_TASK_RESULT_TIMEOUT_SECONDS`:
+ * 用于控制客户端等待任务完成并进入终态的最长时间。
+ * 默认为 `3600` 秒,需设置为大于等于 `1` 的数值。
+ * 适用于 `mineru`、`mineru-gradio` 和 `mineru-router` 等通过 API 客户端轮询任务状态的场景。
+
+- `MINERU_TASK_RESULT_DOWNLOAD_TIMEOUT_SECONDS`:
+ * 用于控制任务完成后获取结果的读取超时时间,包括服务端生成 ZIP 的等待和结果 ZIP 下载。
+ * 默认为 `600` 秒,需设置为大于等于 `1` 的数值。
+ * 该配置不代表整个下载过程的总耗时硬上限;如果服务端持续返回数据,整体下载时间可能超过该值。
+
- `MINERU_API_TASK_RETENTION_SECONDS`:
* 用于设置任务完成或失败后的保留时长(秒)
* 默认为 `86400` 秒(24 小时)。
diff --git a/mineru/cli/api_client.py b/mineru/cli/api_client.py
index f19b7db7..ad81cd46 100644
--- a/mineru/cli/api_client.py
+++ b/mineru/cli/api_client.py
@@ -96,6 +96,18 @@ def get_task_result_timeout_seconds(default: float = 3600.0) -> float:
TASK_RESULT_TIMEOUT_SECONDS = get_task_result_timeout_seconds()
+def get_task_result_download_timeout_seconds(default: float = 600.0) -> float:
+ """读取任务结果下载超时时间,避免和任务处理等待超时混用。"""
+ return get_float_env(
+ "MINERU_TASK_RESULT_DOWNLOAD_TIMEOUT_SECONDS",
+ default,
+ minimum=1.0,
+ )
+
+
+TASK_RESULT_DOWNLOAD_TIMEOUT_SECONDS = get_task_result_download_timeout_seconds()
+
+
def get_local_api_launch_mode(default: str = LOCAL_API_LAUNCH_MODE_SUBPROCESS) -> str:
value = os.getenv(MINERU_LOCAL_API_LAUNCH_MODE_ENV)
if value is None:
@@ -629,7 +641,7 @@ def build_http_timeout() -> httpx.Timeout:
def build_result_download_timeout() -> httpx.Timeout:
return httpx.Timeout(
connect=10,
- read=TASK_RESULT_TIMEOUT_SECONDS,
+ read=TASK_RESULT_DOWNLOAD_TIMEOUT_SECONDS,
write=300,
pool=30,
)