Problem tokyo 0.3 thread 'main' panicked at 'not currently running on the Tokio runtime.' [Solved]

Hi to all, i'm trying to upgrade a rust program that download manga to the new version of tokio, but i'm having problem when i execute the code:

thread 'main' panicked at 'not currently running on the Tokio runtime.'

i copy the code main code:

async fn main() -> Result<(), Box<dyn std::error::Error>>{
    let mut f = tokio::fs::File::open("mangatown.txt").await.expect("Fallo al abrir fichero mangatown.txt");

    let mut buffer = String::new();
    f.read_to_string(&mut buffer).await.expect("Fallo al leer fichero mangatown.txt");

    //println!("{:?}", buffer);
    let vec: Vec<&str> = buffer.split('\n').collect();
    for line in vec {
        let url = Url::parse(&line).expect("Fallo en la tranformación url de la serie");
    	println!("Lo ha intentado")

and the signature function that i don't see the execution is this:

async fn bajar_manga(url_serie: Url) {
    println!("this is a test to see calling in the tokio 0.3")

i'm not very sure why i can't call my async fn with await in the main that have the tokyo runtime.

Sorry english ins not my first language

Works fine on the playground after fixing compilation. Is there anything else you omitted in the code you pasted here? The problem may be there.

I have copy my code, i know that i have warnings about the function borrar_directorio_y_panic (i know that this function doesn't do anithing because how i'm calling it)

i can pass my cargo.toml

name = "scrape_mangatown_reqwest"
version = "3.0.0"
authors = ["Guillermo Cabezas <>"]
edition = "2018"

tokio = { version = "0.3.0", features = ["full"]  }
tokio-fs = "0.1.6"
select = "0.5.0"
reqwest = { version = "0.10.0", features = ["rustls-tls"]}
ansi_term = "0.12.1"
url = "2.1.0"

lto = "fat"

Now it'seems that don't compile in the playground and i don't why

I can't reproduce the error on the playground locally. You can try to open an issue. As for the panic you got, I can reproduce it locally. The problem is probably that you depend on tokio 0.3.0, but then use tokio 0.2.22 through reqwest. When I switch the tokio 0.3.0 dependency to 0.2.22 it works without problem. Or at least I assume that the following is the expected output:
this is a test to see calling in the tokio 0.3 No se ha podido obtener la información del manga
Lo ha intentado

Ok, now i'm seeing that i'm using the tokio-fs and it's deprecated, and what are you talking about the reqwest is perhaps the problem because in the terminal when i'm running the program i see:

thread 'main' panicked at 'not currently running on the Tokio runtime.', /home/kapoira/.cargo/registry/src/

and i'm trying to use tokio 0.3.0 not 0.2.22

The problem is that you are trying to use tokio 0.3.0 when one of your dependencies only supports 0.2.22.

1 Like

Many thanks, to make me understand this problem (i changed the title to solved) and i will wait to next version of reqwest to only use tokyo 0.3

1 Like

Yeah this is right. Just to be exact, reqwest version 0.1 depends on tokio version 2.0. Changing tokio back to 2.0 instead of 3.0 fixes this issue. Hopefully the next version of reqwest will be compatible with tokio 3.0

1 Like