{"record":{"id":"edadccf70691f54c","repo":"PaddlePaddle/PaddleOCR","slug":"request-timed-out-e-edadcc","errorCode":null,"errorMessage":"Request timed out: {e}","messagePattern":"Request timed out: (.+?)","errorType":"exception","errorClass":"RequestTimeoutError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/_resources.py","lineNumber":50,"sourceCode":"    filename: Optional[str] = None,\n    timeout: float = 300.0,\n) -> str:\n    if not resource_url:\n        raise InvalidRequestError(\"resource_url is required.\")\n    if not destination:\n        raise InvalidRequestError(\"destination is required.\")\n\n    parsed_url = urlparse(resource_url)\n    if parsed_url.scheme not in (\"http\", \"https\") or not parsed_url.netloc:\n        raise InvalidRequestError(f\"Invalid resource URL: {resource_url}\")\n\n    target = _resolve_destination(parsed_url.path, destination, filename)\n    _require_writable_target(target, overwrite)\n\n    try:\n        response = requests.get(resource_url, timeout=timeout)\n    except requests.Timeout as e:\n        raise RequestTimeoutError(f\"Request timed out: {e}\") from e\n    except requests.ConnectionError as e:\n        raise NetworkError(f\"Connection failed: {e}\") from e\n\n    try:\n        response.raise_for_status()\n    except requests.RequestException as e:\n        raise NetworkError(f\"Failed to download resource: {e}\") from e\n\n    _atomic_write(target, response.content, overwrite)\n    return str(target)\n\n\ndef save_ocr_result_resources(\n    result: OCRResult,\n    destination: str,\n    *,\n    overwrite: bool = False,\n    timeout: float = 300.0,","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_resources.py#L32-L68","documentation":"RequestTimeoutError raised when the underlying requests.get(resource_url, timeout=...) raises requests.Timeout while downloading a result resource. The default timeout is 300 seconds (connect+read applied per blocking operation by requests).","triggerScenarios":"save_resource downloading a large OCR result image over a slow link so a single blocking read exceeds the timeout; or the server stalls mid-transfer. Note: requests' timeout is per-socket-operation, not total transfer time, so slow-but-flowing transfers can still succeed while stalled transfers raise.","commonSituations":"Downloading high-resolution OCR page images (tens of MB) on constrained bandwidth; server under heavy load stalling reads; timeout left at a default too small for big artifacts; proxies adding latency.","solutions":["Increase the timeout argument (save_resource(..., timeout=900)) for large files","Retry the download — transient stalls often succeed on a second attempt","Check file size first (HEAD request) and scale the timeout to expected size","If downloads consistently stall, diagnose network path (proxy, MTU, server throughput)"],"exampleFix":"# before\nsave_resource(url, dest)  # default timeout=300.0\n\n# after\nsave_resource(url, dest, timeout=900.0)","handlingStrategy":"retry","validationCode":"size = int(requests.head(url, timeout=30).headers.get('content-length', 0))\ntimeout = max(300, size / 100_000)  # scale with bytes, ~100KB/s floor","typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        save_resource(url, dest, timeout=900)\n        break\n    except RequestTimeoutError:\n        if attempt == 2: raise\n        time.sleep(2 ** attempt)","preventionTips":["Scale the timeout argument to expected artifact size","Retry timeouts — mid-transfer stalls are frequently transient","Avoid downloading very large result images on restricted links during peak hours"],"tags":["timeout","download","network"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}