Skip to content

Commit 24acdc0

Browse files
committed
Reduce the number of threads iron uses during tests
It defaults to 8 * num_cpus, and we leak these threads since we can't shut iron down, so on my 20-core machine it was hitting 11,500 idle threads during the test run.
1 parent 986f477 commit 24acdc0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/web/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,11 @@ impl Server {
430430
context: &dyn Context,
431431
) -> Result<Self, Error> {
432432
let cratesfyi = CratesfyiHandler::new(template_data, context)?;
433-
let inner = Iron::new(cratesfyi)
434-
.http(addr)
435-
.unwrap_or_else(|_| panic!("Failed to bind to socket on {}", addr));
433+
let mut iron = Iron::new(cratesfyi);
434+
if cfg!(test) {
435+
iron.threads = 1;
436+
}
437+
let inner = iron.http(addr).unwrap_or_else(|_| panic!("Failed to bind to socket on {}", addr));
436438

437439
Ok(Server { inner })
438440
}

0 commit comments

Comments
 (0)