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
Specify that runtime should have task scheduler #1839
Specify that runtime should have task scheduler #1839
Conversation
tokio/src/runtime/global.rs
Outdated
@@ -47,7 +47,7 @@ where | |||
// Explicit drop of `future` silences the warning that `future` is | |||
// not used when neither rt-* feature flags are enabled. | |||
drop(future); | |||
panic!("must be called from the context of Tokio runtime"); | |||
panic!("must be called from the context of Tokio runtime with task scheduler"); |
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.
What about:
panic!("must be called from the context of Tokio runtime with task scheduler"); | |
panic!("must be called from the context of Tokio runtime configured with either `basic_scheduler` or `threaded_scheduler`"); |
?
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.
I think that committing ^^ as is will make rustfmt
unhappy though.
Thanks for the panic message PR 👍 I greatly appreciate these kinds of contributions. Fixing pain points is great. |
Also there's still a thing that can confuse people - calling let rt = tokio::runtime::Builder::new().num_threads(4).build().unwrap(); I don't expect that |
Thanks 👍 |
Motivation
If runtime doesn't have task scheduler,
tokio::spawn
from context of this runtime will produce panicmust be called from the context of Tokio runtime
, which is unclear, because it's actually done from the context of runtime. New panic message specifies that runtime should have task scheduler in order to execute spawned tasks.Solution
Changed runtime panic message. Closes #1837.