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:

#[tokio::main]
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 {
    	println!("{}",line);
        let url = Url::parse(&line).expect("Fallo en la tranformación url de la serie");
        bajar_manga(url).await;
    	println!("Lo ha intentado")
    }
    Ok(())
}

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

1 Like

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

[package]
name = "scrape_mangatown_reqwest"
version = "3.0.0"
authors = ["Guillermo Cabezas <kapoira@gmail.com>"]
edition = "2018"

[dependencies]
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"

[profile.release]
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:

https://example.com
this is a test to see calling in the tokio 0.3
https://example.com/ No se ha podido obtener la información del manga
Parando.
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/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/handle.rs:118:28

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.

4 Likes

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

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.