{"record":{"id":"018905e6004a1c01","repo":"XX-net/XX-Net","slug":"time-out","errorCode":null,"errorMessage":"time out","messagePattern":"time out","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"code/default/gae_proxy/local/download_gae_lib.py","lineNumber":59,"sourceCode":"            if not req:\n                time.sleep(3)\n                continue\n\n            if req.status == 302:\n                url = req.headers[\"Location\"]\n                continue\n\n            start_time = time.time()\n            timeout = 300\n\n            if req.chunked:\n\n                downloaded = 0\n                with open(filename, 'wb') as fp:\n                    while True:\n                        time_left = timeout - (time.time() - start_time)\n                        if time_left < 0:\n                            raise Exception(\"time out\")\n\n                        dat = req.read(timeout=time_left)\n                        if not dat:\n                            break\n\n                        fp.write(dat)\n                        downloaded += len(dat)\n\n                return True\n            else:\n                file_size = int(req.getheader('Content-Length', 0))\n\n                left = file_size\n                downloaded = 0\n                with open(filename, 'wb') as fp:\n                    while True:\n                        chunk_len = min(65536, left)\n                        if not chunk_len:","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/XX-net/XX-Net/blob/cfa5bc17b67676e467f37ec50766127e0ab5f0aa/code/default/gae_proxy/local/download_gae_lib.py#L41-L77","documentation":"Raised by download_file in gae_proxy's download_gae_lib.py when the total elapsed time of reading the GAE lib download exceeds the caller-supplied timeout before the stream ends. Each loop iteration computes time_left = timeout - elapsed; once negative it throws a generic Exception('time out'). It is a wall-clock deadline applied to the whole HTTP body read, not a per-read socket timeout.","triggerScenarios":"Calling download_file(url, filename, timeout=N) where the server sends data slower than the body can complete in N seconds, or the connection stalls after partial data; also when the file is large and timeout is too small relative to bandwidth.","commonSituations":"Slow or throttled network to Google/GitHub servers, small hardcoded timeout values, downloading a large archive (e.g. GoAgent lib) over a proxy, temporary server slowness.","solutions":["Increase the timeout argument passed to download_file / download_unzip","Retry the download (transient slowness is common); wrap download_unzip in a retry loop with backoff","Check network/proxy throughput and pause other bandwidth-heavy tasks","If repeatedly timing out at the same byte count, verify the URL still serves the file and isn't hanging"],"exampleFix":"// before\ndownload_unzip(url, target_path, timeout=30)\n// after\nfor i in range(3):\n    try:\n        download_unzip(url, target_path, timeout=300)\n        break\n    except Exception as e:\n        if 'time out' not in str(e) or i == 2:\n            raise\n        time.sleep(5)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    download_unzip(url, path, timeout=600)\nexcept Exception as e:\n    if 'time out' in str(e):\n        # transient: retry with bigger budget\n        download_unzip(url, path, timeout=1800)\n    else:\n        raise","preventionTips":["Pass a timeout sized to file size over worst-case bandwidth, not best-case","Wrap module downloads in a bounded retry loop with backoff","Monitor elapsed progress so stalls are detected before the hard deadline"],"tags":["network","timeout","download","gae-proxy"],"backgroundTag":"download-timeout","analyzedSha":"cfa5bc17b67676e467f37ec50766127e0ab5f0aa","analyzedAt":"2026-08-27T19:28:28.225Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}