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

there is no reactor running, must be called from the context of a Tokio 0.2.x runtime #238

Open
GabeDuarteM opened this issue Aug 14, 2022 · 2 comments

Comments

@GabeDuarteM
Copy link

I'm trying to run the tokio example, but whenever we hit the line let mut runner = AsyncRunner::connect(connector, &user_config).await?; (https://github.com/museun/twitchchat/blob/master/examples/tokio_demo.rs#L20), I get the following error:

thread 'main' panicked at 'there is no reactor running, must be called from the context of a Tokio 0.2.x runtime', [home]/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.25/src/io/driver/mod.rs:203:30
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

my Cargo.toml has tokio = { version = "1.20.1", features = ["rt-multi-thread", "macros"] }, but if I change the version to 0.2.25 to match the runtime said on the error, I then get the following (it changes to Tokio 1.x runtime instead of Tokio 0.2.x runtime):

thread 'main' panicked at 'there is no reactor running, must be called from the context of a Tokio 1.x runtime', [home]/.cargo/registry/src/github.com-1ecc6299db9ec823/hyper-0.14.20/src/client/connect/dns.rs:121:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm new to rust, so this might be trivial, but I have no idea which other packages might be using tokio, and also not sure downgrading it is the best approach (I'd prefer to use the latest version, if possible)

My full Cargo.toml:

[package]
name = "thing"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
dotenv = "0.15.0"
reqwest = "0.11.11"
tokio = { version = "0.2.25", features = ["macros"] }
twitchchat = { version = "0.14.8", features = ["async", "tokio", "tokio-util"] }
twitch_oauth2 = { version = "0.7.0", features = ["reqwest"] }

anyhow = "1.0.59"
serde = "1.0.143"
serde_json = "1.0.83"

Is this really only solvable by downgrading all the packages until they all use the same tokio version?

@museun
Copy link
Owner

museun commented Aug 27, 2022

I can perhaps push an update to upgrade to tokio 1.0, this crate has been in basically dormant mode for a while now.

But you can still use this crate without tokio -- just as the parser/encoder/decoder.

@Emilgardis
Copy link
Collaborator

Emilgardis commented Sep 1, 2022

you should be able to use the current master branch for tokio 1

twitchchat = { git = "https://github.com/museun/twitchchat", version = "0.14.8", features = ["async", "tokio", "tokio-util"] }

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

3 participants