mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 04:48:18 +00:00
Support setting request timeout with UV_HTTP_TIMEOUT and HTTP_TIMEOUT (#1780)
Follow-up to #1694 matching Cargo's environment variable names https://doc.rust-lang.org/nightly/cargo/reference/config.html#httptimeout
This commit is contained in:
parent
d07b587f3f
commit
3cd51ffc92
1 changed files with 10 additions and 10 deletions
|
|
@ -88,17 +88,17 @@ impl RegistryClientBuilder {
|
|||
|
||||
pub fn build(self) -> RegistryClient {
|
||||
let client_raw = self.client.unwrap_or_else(|| {
|
||||
// Get pip timeout from env var
|
||||
// Timeout options, matching https://doc.rust-lang.org/nightly/cargo/reference/config.html#httptimeout
|
||||
// `UV_REQUEST_TIMEOUT` is provided for backwards compatibility with v0.1.6
|
||||
let default_timeout = 5 * 60;
|
||||
let timeout = env::var("UV_REQUEST_TIMEOUT")
|
||||
.map_err(|_| default_timeout)
|
||||
.and_then(|value| {
|
||||
value.parse::<u64>()
|
||||
.map_err(|_| {
|
||||
warn_user_once!("Ignoring invalid value for UV_REQUEST_TIMEOUT. Expected integer number of seconds, got {value}.");
|
||||
default_timeout
|
||||
})
|
||||
}).unwrap_or(default_timeout);
|
||||
let timeout = env::var("UV_HTTP_TIMEOUT").or_else(|_| env::var("UV_REQUEST_TIMEOUT")).or_else(|_| env::var("HTTP_TIMEOUT")).and_then(|value| {
|
||||
value.parse::<u64>()
|
||||
.or_else(|_| {
|
||||
// On parse error, warn and use the default timeout
|
||||
warn_user_once!("Ignoring invalid value from environment for UV_REQUEST_TIMEOUT. Expected integer number of seconds, got \"{value}\".");
|
||||
Ok(default_timeout)
|
||||
})
|
||||
}).unwrap_or(default_timeout);
|
||||
debug!("Using registry request timeout of {}s", timeout);
|
||||
// Disallow any connections.
|
||||
let client_core = ClientBuilder::new()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue