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

Ability to choose b/w blocking and non-blocking client for reqwest #367

Closed
thatdevsherry opened this issue Nov 14, 2020 · 2 comments
Closed

Comments

@thatdevsherry
Copy link
Contributor

Problem

I had started working on the code I wrote involving prometheus sometime back. At that time the push function worked fine but now the code panics. The output of panic is:

thread 'main' panicked at 'Cannot drop a runtime in a context where blocking is not allowed. This happens when a runtime is dropped from within an asynchronous context.', /Users/phoenix/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.22/src/runtime/blocking/shutdown.rs:49:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
2020-11-14 08:42:05,631 TRACE [mio::sys::unix::kqueue] registering; token=Token(18446744073709551615); interests=Readable
2020-11-14 08:42:05,631 TRACE [mio::poll] registering with poller
2020-11-14 08:42:05,631 TRACE [reqwest::blocking::client] (ThreadId(12)) start runtime::block_on

Debugging

The last line made me figure out that rust-prometheus is using the blocking reqwest client. I was using the #[tokio::main] attribute to make the main() fn async. I believe using this and the blocking reqwest client causes this issue. Maybe the TRACE shows that is tries to use runtime::block_on which inside #[tokio::main] calls shutdown in tokio which has this panic line.

Would allowing the user to choose b/w blocking & non-blocking client solve this issue?

@breezewish
Copy link
Member

breezewish commented Nov 16, 2020

Hi, there is an on-going PR that provides non-blocking clients. Would you like to try with it? #343

Also see #342

@thatdevsherry
Copy link
Contributor Author

@breeswish oh my bad I should've searched the issues before, I'll keep an eye on issue #342 and PR #343

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

2 participants