Skip to content

Avoid creating unnecessary thread pool#10

Open
tdryer wants to merge 2 commits intoreu:masterfrom
tdryer:unnecessary-thread-pool
Open

Avoid creating unnecessary thread pool#10
tdryer wants to merge 2 commits intoreu:masterfrom
tdryer:unnecessary-thread-pool

Conversation

@tdryer
Copy link

@tdryer tdryer commented Dec 19, 2025

Unless the threadpool feature is disabled, Server always contains a thread pool, even if it is unnecessary because the Server is only used with serve_single_thread. Fix this by deferring creating the thread pool until it is actually required.

I noticed this because I was getting resource exhaustion errors when running a single-threaded server in a podman container, which restricts the number of threads. Disabling the threadpool feature also fixes this, but this must be done explicitly since it's a default feature.

Also:

Fix clippy warnings about replacing io::Error::new(io::ErrorKind::Other, ...) with io::Error::other(...).

Unless the `threadpool` feature is disabled, `Server` always contains a
thread pool, even if it is unnecessary because the `Server` is only used
with `serve_single_thread`. Fix this by deferring creating the thread
pool until it is actually required.

I noticed this because I was getting resource exhaustion errors when
running a single-threaded server in a podman container, which restricts
the number of threads. Disabling the `threadpool` feature also fixes
this, but this must be done explicitly since it's a default feature.
Fix clippy warnings about replacing
`io::Error::new(io::ErrorKind::Other, ...)` with
`io::Error::other(...)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant