-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rt: blocking runtime doesn't reponse shutdown flag #5275
Conversation
We should check the shutdown flag before the next iteration to interrupt the execution asap, the current implementation doesn't respond to shutdown until queue cleans
Hi, thank you for the PR. I missed it when you originally submitted it. Your PR causes the following test to fail: tokio/tokio/tests/rt_handle_block_on.rs Lines 195 to 210 in 7299304
|
According to the test it seems like we (try to) guarantee that tasks spawned before shutdown will complete, but if we really guaranteed that, then #4296 wouldn't be necessary. I don't really understand what's going on with that. |
hi, Thanks for the reply. I'm not sure if tokio is try to guarantee all spawned tasks to complete even runtime is shutdown, but it seems not very conform to the current code design. Checked the if shared.shutdown {
// Drain the queue
while let Some(task) = shared.queue.pop_front() {
self.metrics.dec_queue_depth();
drop(shared);
task.shutdown_or_run_if_mandatory(); So, as my understanding, after the runtime is shutdown, only mandatory tasks will be executed, other tasks should be aborted. |
Hi, sorry about the delay. It seems like you're correct. We don't guarantee that in general, but it happens to be true for the "first started task". It's not a real guarantee. Please go ahead and delete the test in question. |
Any updates on this? If you remove the faulty test, then I would be happy to merge this. |
oh, Sorry I've been busy with other projects, I'll find time this weekend to work on this :) |
there exists other test case failed which I can't figure out why. :(, maybe the test case also consider all spawned task should be executed even if runtime is shutdown. I'll close this pull request as I thinks is just a design choice not a bug :) #[test]
fn pool_shutdown() {
loom::model(|| {
let pool = mk_pool(2);
pool.spawn(track(async move {
gated2(true).await;
}));
pool.spawn(track(async move {
gated2(false).await;
}));
drop(pool);
});
} |
We should check the shutdown flag before the next iteration to interrupt the execution asap, the current implementation doesn't respond to shutdown until queue cleans
Motivation
Solution