Replies: 2 comments 15 replies
-
Tokio timers not intended to be precise, so this is a expected behavior. Technically, tokio doesn't poll the expired timers after each |
Beta Was this translation helpful? Give feedback.
-
The |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Clarification to the title:
tokio::time::timeout
doesn't deterministically timeout at await boundary (way past the timeout duration).I created this MRE with a colleague. Basically, I'm trying to do
timeout
on a repeating heavy computation. I've addedtokio::task::yield_now().await
between batches of computation. Each batch is much longer than thetimeout
duration. However, the task does not get cancelled after the first computation. Note that if I useselect! { /* computation */, _ = tokio::sleep(...) }
to implement the timeout, everything works as expected.Please, help me understand why that is. And whether
select!
will in fact offer better timing guarantees.The example I described above is here (playground link):
Using
select!
works: link.Beta Was this translation helpful? Give feedback.
All reactions