-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
runtime: clarify the behavior of Handle::block_on
#7665
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -252,6 +252,15 @@ impl Handle { | |||||
/// timers will not work unless there is another thread currently calling | ||||||
/// [`Runtime::block_on`] on the same runtime. | ||||||
/// | ||||||
/// If this function is called from within a Tokio runtime's asynchronous | ||||||
/// context, such as inside a [`Runtime::block_on`] scope, or from a function | ||||||
/// annotated with the [`tokio::main`] attribute macro, it will panic, because | ||||||
/// nesting runtimes is not allowed. | ||||||
/// The same applies when calling `Handle::block_on` to re-enter the current | ||||||
/// runtime. To safely run asynchronous code from such a context, you can use | ||||||
/// [`task::block_in_place`] (only available with the multi-thread scheduler), | ||||||
/// as shown in the example below. | ||||||
ADD-SP marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
/// | ||||||
/// # If the runtime has been shut down | ||||||
/// | ||||||
/// If the `Handle`'s associated `Runtime` has been shut down (through | ||||||
|
@@ -306,6 +315,23 @@ impl Handle { | |||||
/// # } | ||||||
/// ``` | ||||||
/// | ||||||
/// `Handle::block_on` may use [`task::block_in_place`] to re-enter the async context of a multi-thread scheduler runtime: | ||||||
|
/// `Handle::block_on` may use [`task::block_in_place`] to re-enter the async context of a multi-thread scheduler runtime: | |
/// `Handle::block_on` may be combined with [`task::block_in_place`] to re-enter the async context of a multi-thread scheduler runtime: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, also reflow the text with a line break at 80 or 100 chars (whatever the rest of the file is using).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thanks
Uh oh!
There was an error while loading. Please reload this page.