-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Cannot be shared between threads safely #241
Comments
This is a unfortunate consequence of trait objects. Hyper's response future doesn't impl Sync but streams currently require that. I would suggest spawning the future that awaits the hyper request and use a channel to get the reply back. Since the channel will impl Sync. |
Thanks, I already had the idea that I had to wrap the operation. I will give it a try and if it does not work, I might come back here and reopen the issue. Thanks for the suggestion, and again for the wonderful library. |
@LucioFranco Maybe you could include an example in the docs how to solve an issue like this. When I started using a channel, I got into more problems ( Instead of streaming I will redesign my gRPC proto and use |
@frederikbosch this #117 (comment) might help since it is quite similar to your case, I think it might also be solved by spawning a task using |
@frederikbosch does this example help at all? https://github.com/hyperium/tonic/blob/master/examples/src/routeguide/server.rs#L51 |
I used the suggestion by @abdul-rehman0, and that worked. Fantastic. My own not working code used However, I still have to add Anyway, thank you both for helping me out. |
@frederikbosch the recursion limit is usually due to usage of a |
Bug Report
I cannot solve the following error. I guess I lack knowledge, but I have no idea where to start solving this one.
Version
cargo / rust 1.40.0
tonic 0.1.0.
Platform
Ubuntu 18.04
Crates
reqwest = { version = "0.10.0", features = ["json"]}
Description
What I am trying to is the following. I have service that receives a gRPC call from client. That service will fire a HTTP request via reqwest before it answers the client. That reqwest is also async. In pseudo-code (sort of) I have the following.
And then in the library I am calling I have.
The result is huge error.
The text was updated successfully, but these errors were encountered: