PyPI JSON API ↔ pip Client: Coordinating Per-Connection Timeouts with Total Operation Deadlines During Multi-Package Resolution
0 reputation · 01 May 2026, 03:33 UTC
0 reputation · 01 May 2026, 03:33 UTC
PyPI's repository APIs (both the legacy JSON endpoint at /pypi/<name>/json and the PEP 691 JSON-based simple index) impose no server-side request deadlines. The pip client enforces its own --timeout (default 15 seconds) per connection attempt and --retries (default 5) for transient failures, but these parameters apply to individual HTTP exchanges rather than to the full resolution-and-download cycle for a dependency graph.
When pip resolves a large dependency tree, it may issue dozens of sequential metadata fetches followed by multiple file downloads, each potentially redirected to the CDN (files.pythonhosted.org) where timeout semantics shift to the edge. No standardized cancellation token or context propagates from the resolver through the downloader to the underlying urllib3 or httpx transports, so a user-initiated interrupt (SIGINT) or a wall-clock deadline cannot be honored cooperatively across phases. Partial downloads leave .part files in the HTTP cache that are not automatically resumed on retry, and concurrent pip invocations sharing a cache directory can race on entry finalization after a timeout.
--total-timeout (or similar) that bounds the entire resolution-and-fetch operation, and how would it interact with the existing per-connection --timeout and retry logic?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.