Skip to content
Discussion options

You must be logged in to vote

axum expects to be run in a cooperative scheduler, in most cases tokio. Basically, there is a background task which just loops and tries to accept new connections, if it does, it spawns another task to handle that new connection and then listens to new ones. This works well when the accepting operation is non-blocking, if there's no waiting connection, the thread can be reused for other tasks, if you want to cancel it, you just drop it.

On the other hand, if you're using a blocking listener, the thread will have to wait there until there is a new connection and then it can return that. Blocking tokio threads is a bad idea (there's been written a lot about that already) but in this case it…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@mladedav
Comment options

Answer selected by rg-atte
@rg-atte
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #3560 on November 19, 2025 12:55.