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

Example poll.rs: thread 'main' panicked at 'there is no timer running, must be called from the context of a Tokio 0.2.x runtime' #270

Open
robertpauson opened this issue Dec 4, 2022 · 5 comments

Comments

@robertpauson
Copy link

My Cargo.toml:

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

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

[features]
openssl = ["hyper-tls"]
rustls = ["hyper-rustls"]
default = ["openssl"]

[dependencies]
bytes = "1.0.1"
tokio = { version = "1.2", features = ["full"]}

tracing = "0.1.23"
tracing-futures = "0.2"
multipart = { version = "0.17", default-features = false, features = ["client"] }

hyper = { version = "0.14", features = ["client", "http1"] }
hyper-tls = { version = "0.5", optional = true  }
futures = "0.3"
hyper-rustls = { version = "0.22", optional = true }
telegram-bot = "0.8.0"

[dev-dependencies]
tracing-subscriber = "0.2.15"
tokio = { version = "1.2", features = ["full"] }

@ryanhossain9797
Copy link

Are you using an async tokio::main main as an entry point?

@robertpauson
Copy link
Author

yes of course same as in example


#[tokio::main]
async fn main() -> Result<(), Error> {

@citizen-stig
Copy link

Same problem for me, here's my Cargo.toml:

[package]
name = "telegram-bot-sample"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0"
tokio = { version = "1.2", features = ["full"] }
futures = "0.3"
telegram-bot = "0.8"

@citizen-stig
Copy link

citizen-stig commented Dec 30, 2022

Root cause

I run cargo tree and see that latest version(0.8) on crates.io is published about 2 years ago and depends on hyper=0.13, which depends on tokio=0.2.25. Here's trimmed output of cargo tree command:

├── anyhow v1.0.68
├── futures v0.3.25
...
├── telegram-bot v0.8.0
│   ├── bytes v0.5.6
│   ├── futures v0.3.25 (*)
│   ├── hyper v0.13.10
│   │   ├── bytes v0.5.6
│   │   ├── futures-channel v0.3.25 (*)
│   │   ├── futures-core v0.3.25
│   │   ├── futures-util v0.3.25 (*)
│   │   ├── h2 v0.2.7
│   │   │   ├── bytes v0.5.6
...
│   │   │   ├── tokio v0.2.25
...
│   │   ├── tokio v0.2.25 (*)
│   │   ├── tower-service v0.3.2
│   │   ├── tracing v0.1.37 (*)
│   │   └── want v0.3.0
│   │       ├── log v0.4.17 (*)
│   │       └── try-lock v0.2.3
│   ├── hyper-tls v0.4.3
...
│   │   ├── tokio v0.2.25 (*)
│   │   └── tokio-tls v0.3.1
│   │       ├── native-tls v0.2.11 (*)
│   │       └── tokio v0.2.25 (*)
...
│   │       └── serde v1.0.152 (*)
│   ├── tokio v0.2.25 (*)
│   ├── tracing v0.1.37 (*)
│   └── tracing-futures v0.2.5 (*)
└── tokio v1.23.0

Potential solutions for this problem

  1. Publish new version on crates.io, something like 0.8.1. This require some effort from maintainers
  2. Workaround to point to dependency from git, like that:
telegram-bot =  { git = "https://github.com/telegram-rs/telegram-bot.git", rev = "65ad5cf" }

I can confirm that second option worked for me. I hope @robertpauson or @gugahoa can publish new version.

@Dmdv
Copy link

Dmdv commented Mar 21, 2023

Same issue for me
Using this toml

[dependencies]
telegram-bot = "0.8.0"
tokio = { version = "1.26.0", features = ["fs", "rt", "macros", "rt-multi-thread"]}
futures = { version = "0.3.26", default-features = false }
dotenv = "0.15.0"

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