-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
"Cannot start a runtime from within a runtime." false positive? #2529
Comments
Thank you for the bug report. This definitely seems like a bug. Note that this simplified version also panics: use tokio::runtime::Builder;
fn main() {
let mut rt = Builder::new().threaded_scheduler().build().unwrap();
let matching_rt = Builder::new().threaded_scheduler().build().unwrap();
let handle = matching_rt.handle().clone();
rt.block_on(async move {
handle.spawn(async {}).await
}).unwrap();
} |
this example do not panic, but if you replace |
@cssivision Oops, that's what I meant! |
rt.block_on(async move {
matching_rt.spawn(async {}).await
}).unwrap(); The problem here is Changing Relevant parts of the stack trace:
|
@jebrosen Thanks for the diagnosis. Would it be possible to improve this error message to specifically mention it's coming from Tokio's own destructor? Destructors are invisible and I wouldn't have guessed it's about that, and not my |
I suppose that would be possible to do. These panic messages need improvement in any case, but this sounds like a reasonable idea. |
is this issue resolved ? |
Yes, the panic message was fixed in #2646. |
I'm trying to create a second threaded runtime to act as a replacement of
futures-cpupool
(because reasons).This code:
Fails with:
I don't think I'm violating any rules here: both runtimes are created outside of a runtime, and only one of them runs
block_on
.On top of that, using
Handle
forspawn
instead of the runtime directly, makes it work:Is this the expected behavior?
The text was updated successfully, but these errors were encountered: