Skip to content

Subscription stops working after firing 4 Commands #1351

Closed Answered by hecrj
lufte asked this question in Q&A
Discussion options

You must be logged in to vote

Blocking in an async thread breaks the Future contract!

The thread pool used by the executor has a limited number of worker threads. Futures work by polling work. If you block in an async context, you can block all of the worker threads.

You should use tokio::time::sleep and enable the tokio feature:

pub async fn clear_notification() {
    tokio::time::sleep(std::time::Duration::from_secs(3)).await;
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lufte
Comment options

Answer selected by lufte
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