Cannot start a runtime from within a runtime #3857
-
I am trying to create a telegram bot with teloxide scrape.rs
There is no error while compiling and it runs perfectly but when I type /j on telegram it gives me this error
I don't understand what i can do to solve this. I haven't seen this anywhere on the internet yet. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
When you annotate a function with fn main() {
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap()
.block_on(async {
...
})
} So that means that if you call a method annotated with Remove the |
Beta Was this translation helpful? Give feedback.
When you annotate a function with
#[tokio::main]
, that turns the function into this:So that means that if you call a method annotated with
#[tokio::main]
from asynchronous code, you are creating a new runtime while being in asynchronous code.Remove the
#[tokio::main]
annotation fromscape::main
.