Skip to content

long tasks inside actix_rt::spawn blocking main thread #3052

Answered by robjtede
kimutaiRop asked this question in Q&A
Discussion options

You must be logged in to vote

Using thread::sleep in async code is always wrong. Use actix_rt::time::sleep instead.

I though that actix_rt::spawn was supposed to be a way to create some tasks to run in different thread

Not so, if you need to do signifcant blocking calls then actix_web::web::block is required.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by robjtede
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 #3049 on June 19, 2023 05:53.