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

Add note about current_thread + Handle::block_on #5264

Merged
merged 1 commit into from Dec 5, 2022
Merged

Add note about current_thread + Handle::block_on #5264

merged 1 commit into from Dec 5, 2022

Conversation

sharnoff
Copy link
Contributor

@sharnoff sharnoff commented Dec 5, 2022

A friend ran into the current_thread + Handle::block_on IO-bound task issue today; I figured an additional note about it in the docs may be helpful.

There's already an existing warning about this combination in the documentation for Handle::block_on. This PR adds a warning in the docs for Runtime::handle and points to Handle::block_on for more info.

If this isn't something y'all are interested in, I would totally understand - I figured it doesn't take long to make a PR, so it's easier to discuss here :)

There's already an existing warning about this combo in the
documentation for `Handle::block_on`. This commit adds a summarized
version in `Runtime::handle`.
@github-actions github-actions bot added the R-loom Run loom tests on this PR label Dec 5, 2022
@obi1kenobi
Copy link
Contributor

I'm the friend in question, and the note added here would have saved me quite a bit of headache. I found Runtime::handle in the docs, then saw the Handle type also had a block_on method and incorrectly assumed it'd behave identically to Runtime::block_on. Thank you, @sharnoff, for putting this together! 💯

@Noah-Kennedy Noah-Kennedy merged commit 86ffabe into tokio-rs:master Dec 5, 2022
@Noah-Kennedy
Copy link
Contributor

Thanks!

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-runtime Module: tokio/runtime labels Dec 5, 2022
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-runtime Module: tokio/runtime R-loom Run loom tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants