Skip to content
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

Documentation is inconsistent about Runtime shutdown behaviour #4231

Closed
jbg opened this issue Nov 14, 2021 · 1 comment · Fixed by #5394
Closed

Documentation is inconsistent about Runtime shutdown behaviour #4231

jbg opened this issue Nov 14, 2021 · 1 comment · Fixed by #5394
Labels
A-tokio Area: The main tokio crate M-task Module: tokio/task T-docs Topic: documentation

Comments

@jbg
Copy link
Contributor

jbg commented Nov 14, 2021

Version
1.13.0 (also Git master)

Platform
n/a

Description
The module-level documentation for tokio::runtime says:

Once Runtime is dropped, all runtime threads are forcibly shutdown. Any tasks that have not yet completed will be dropped.

However, the documentation for tokio::runtime::Runtime::shutdown_timeout says:

[...] dropping a Runtime will wait indefinitely for all tasks to terminate, [...]

This has lead to confusion over the expected behaviour when a Runtime is dropped.

The module-level documentation appears to be accurate; dropping Runtime will not wait for any tasks to terminate.

@jbg jbg added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Nov 14, 2021
@Darksonn Darksonn added M-task Module: tokio/task T-docs Topic: documentation and removed C-bug Category: This is a bug. labels Nov 14, 2021
@Darksonn
Copy link
Contributor

Well, it's more complicated. The runtime will immediately attempt to kill all tasks, but it may not be able to do so immediately for some of the tasks - a task that is currently running cannot be killed until the next time it yields (reaches an .await), and spawn_blocking tasks cannot be killed whatsoever. The runtime will kill all tasks as fast as it can, but if there are tasks that it can't kill, it will wait indefinitely for them to either finish or become killable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-task Module: tokio/task T-docs Topic: documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants