Skip to content
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

thread 'main' 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.4.0/src/runtime/context.rs:37:26 #68

Open
Json1949 opened this issue Apr 1, 2021 · 6 comments

Comments

@Json1949
Copy link

Json1949 commented Apr 1, 2021

main.rs

let main_redis = redis_async::client::paired_connect("172.0.0.1:6800".parse().unwrap()).await.unwrap();

Cargo.toml

[dependencies]
actix-web = "*"
async-trait = "*"


redis-async = "*"

sqlx = { version = "0.4.1", features = [ 'runtime-actix-rustls', "mysql" ] }
async-std = { version = "1.6", features = [ "attributes" ] }

#redis = { version = "0.19.0", features = ["async-std-tls-comp"] }


serde = { version = "*", features = ["derive"] }
serde_json = "*"
@nazar-pc
Copy link
Contributor

nazar-pc commented Apr 9, 2021

You need to run this under Tokio 1.0 like error says. According to Cargo.toml and incomplete main.rs you might be running it under async-std runtime instead.

@benashford
Copy link
Owner

Yes, this looks to be the case.

I do have experimental support for async-std in a branch, but this isn't ready yet. The current default is Tokio 1.x, but there is also support for Tokio 0.2 behind a feature flag if necessary.

@jesse996
Copy link

jesse996 commented May 1, 2021

same problem,i also use it in actix_web,and get this error

@benashford
Copy link
Owner

Hello, unfortunately I'm not familiar with Actix Web, but @nazar-pc 's comment above is correct in the sense this error means that a Tokio runtime isn't running which is required for this library to work.

So I'm guessing something has recently changed with Actix Web, perhaps allowing it to run under different async runtimes?

But if Actix is still Tokio based then something else is going on.

@nazar-pc
Copy link
Contributor

nazar-pc commented May 4, 2021

Actix-web 3.x uses Tokio 0.2, while 4.x (which is beta currently) switched to Tokio 1.0.
Just pick versions correctly, there is nothing to do about it in this crate.

@Json1949
Copy link
Author

You need to run this under Tokio 1.0 like error says. According to Cargo.toml and incomplete main.rs you might be running it under async-std runtime instead.

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants