Skip to content

Async vs Sync handlers #2884

Discussion options

You must be logged in to vote

Rocket starts a tokio runtime, and every method is executed on the async runtime. The general advice I would give, is that you should always use tokio types for doing any kind of IO, especially network/file IO. Handlers only need to be marked as async if you use any of these types, and call .await inside them. Clippy has a warning for async functions that don't use .await, but it's up to you whether you remove the async marker from your functions that don't need it.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by the10thWiz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants