Cannot start a runtime within a runtime with #[tokio::test] #4779
Unanswered
cryptoquick
asked this question in
General
Replies: 1 comment 2 replies
-
I'm assuming that your library spawns a tokio runtime internally. You shouldn't do this. It's generally far better to just make functions async than to try and supply an executor like this, because you can't guarantee that you aren't being called from within the context of another executor. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to make a test that makes a couple of async calls within a library I'm building to things that use reqwest and stuff under the hood. I'm getting the error,
Cannot start a runtime from within a runtime
. What's unfortunate, though, is that I won't benefit from?
error bubbling in my test if I just try to spawn the thread there, like this:I tried anyway, and then I got issues
generator cannot be sent between threads safely
:What's the best way to solve this issue?
Beta Was this translation helpful? Give feedback.
All reactions