-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
block_in_place with nested block_on allows async drop #5843
Comments
Yes, that's what |
Thanks for the reply. Yes, the behavior in a current-thread runtime was clear from What is smelly to me is that we are able to "re-enter" the async runtime from any place, seems strange it isn't abused e.g. to obtain async drop. |
@Darksonn sorry for the tag but I need a little clarification. There are two factors here:
but how does those two works together? Is the await time in the current thread "spoiled" because queued tasks were already moved to another worker and, because of block_in_place, no other task will be added to current thread? |
When you call At that point, the thread behaves like any other thread outside of the runtime. You can call (Technically, if the call to |
This also sometimes seems to hang on Runtime drop. If you |
Version
All versions since 1.4 (prior versions doesn't have
Handle::block_on
but probably works here too with minimal adaptation.Description
Using
tokio::task::block_in_place
with a nestedtokio::runtime::Handle::block_on
allows using async code in sync context, e.g. onDrop
implementation.E.g.
this code panics with
But simply wrapping
block_on
in ablock_in_place
everything works:Is this the desired behavior?
The text was updated successfully, but these errors were encountered: