-
In the project I maintain we have a code like this:
We can store the JoinHandle of the task, and
I don't see any nice way to do 1 or 3. For 3, there is yield_now, but it is not guaranteed to yield to executor as there may be some combinators in the stack above it. I'm leaning towards entering a loop with yield_now (and maybe logging error / panicking if we are still in this loop after a few seconds). This seems like extremely ugly solution, is there any nicer way to handle executor shutdown? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
If you take the solution of awaiting the |
Beta Was this translation helpful? Give feedback.
In principle you don't know that you will be shut down. Maybe the tasks are on different runtimes, and only one was shut down?
If you're going to just sleep until you get cancelled too, then
std::future::pending().await
would be better than a loop.