Replies: 1 comment 5 replies
-
You can use https://docs.rs/tokio/latest/tokio/runtime/struct.Handle.html#method.try_current to check if you are currently in a runtime context. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In my library, I have a function
f
that sometimes (but not always) ends up callingtokio::sync::mpsc::Receiver::blocking_recv
.The expected usage is that
f
is not called from within an asynchronous context, however this sometimes this requirement is missed. Unfortunately, this means thatf
sometimes (but not always) panics due to use ofblocking_recv
.It would be great to be able to add a
debug_assert!
withinf
to make sureblocking_recv
will succeed, however best I can tell this requires access totokio::runtime::enter::*
which is not public.Is there another way to achieve what I'm after?
Beta Was this translation helpful? Give feedback.
All reactions