Skip to content

Commit 15860cc

Browse files
Nemo157Joshua Nelson
authored and
Joshua Nelson
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 5e8dc3c commit 15860cc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/web/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +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)
433+
let mut iron = Iron::new(cratesfyi);
434+
if cfg!(test) {
435+
iron.threads = 1;
436+
}
437+
let inner = iron
434438
.http(addr)
435439
.unwrap_or_else(|_| panic!("Failed to bind to socket on {}", addr));
436440

0 commit comments

Comments
 (0)