Skip to content

Commit

Permalink
Add limit on connection pool to prevent stalling issues in pyo3 and o…
Browse files Browse the repository at this point in the history
…ther ffi boundaries
  • Loading branch information
hellovai committed Oct 11, 2024
1 parent 2dd1bb6 commit 4808a8f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions engine/baml-runtime/src/request/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn builder() -> reqwest::ClientBuilder {
// regularly have requests that take multiple minutes, due to how
// long LLMs take
.connect_timeout(Duration::from_secs(10))
.danger_accept_invalid_certs(danger_accept_invalid_certs)
.danger_accept_invalid_certs(danger_accept_invalid_certs)
.http2_keep_alive_interval(Some(Duration::from_secs(10)))
}
}
Expand All @@ -27,9 +27,13 @@ pub(crate) fn create_tracing_client() -> Result<reqwest::Client> {
if #[cfg(target_arch = "wasm32")] {
let cb = builder();
} else {
let cb =builder()
let cb = builder()
// Wait up to 30s to send traces to the backend
.read_timeout(Duration::from_secs(30));
.read_timeout(Duration::from_secs(30))
// We don't want to keep idle connections around due to sometimes
// causing a stall in the connection pool across FFI boundaries
// https://github.com/seanmonstar/reqwest/issues/600
.pool_max_idle_per_host(0);
}
}

Expand Down

0 comments on commit 4808a8f

Please sign in to comment.