Tokio no reactor running error
Author: shinglyuCreated Aug 23, 2022Updated Apr 24, 2025
I'm running the AWS Rust SDK in a notebook.
I have the following cells: Cell 1:
:dep aws-config = "0.47.0"
:dep aws-sdk-sagemaker = "0.17.0"
:dep aws-sdk-sagemakerruntime = "0.17.0"
:dep tokio = { version = "1", features = ["full"]}
:dep aws-smithy-types-convert = { version = "0.47.0", features = ["convert-chrono"] }Cell 2:
let config = aws_config::load_from_env().await;If I try to use the config variable in subsequent cells, for example:
let client = aws_sdk_sagemaker::Client::new(&config);
let job_details = client.list_training_jobs().send().await?;I got the following error:
thread '<unnamed>' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime', /root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.20.1/src/runtime/context.rs:55:26Not sure if this is related to how evcxr reuses the Tokio runtime? The Rust SDK also uses Tokio.
I tried a workaround by repeating the following line in every cell that needs it:
let config = aws_config::load_from_env().await;But then the code only works for the first execution, the 2nd call fails with some kind of timeout which I still need to debug further.
Source: evcxr/evcxr