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 (#1027)

<!-- ELLIPSIS_HIDDEN -->



> [!IMPORTANT]
> Set `pool_max_idle_per_host(0)` in `create_tracing_client()` to
prevent connection pool stalling issues across FFI boundaries.
> 
>   - **Behavior**:
> - Set `pool_max_idle_per_host(0)` in `create_tracing_client()` in
`mod.rs` to prevent stalling issues across FFI boundaries.
> - Addresses issue seanmonstar/reqwest#600.
>   - **Misc**:
>     - Minor formatting change in `mod.rs`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup>
for 4808a8f. It will automatically
update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
hellovai authored Oct 11, 2024
1 parent 2dd1bb6 commit eb90e62
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 eb90e62

Please sign in to comment.