GithubHelp home page GithubHelp logo

Comments (8)

LucioFranco avatar LucioFranco commented on July 30, 2024 1

@NeoLegends sorry for the delay, this should be done! Let me know if you run into any issues. I plan to get a new release out soon.

from tonic.

LucioFranco avatar LucioFranco commented on July 30, 2024 1

@parasyte you're right...I'm not sure how to move forward on this one @seanmonstar any ideas?

from tonic.

NeoLegends avatar NeoLegends commented on July 30, 2024

In case you accept this I have already filed PR #82 that applies the necessary change. Feel free to close it otherwise.

from tonic.

parasyte avatar parasyte commented on July 30, 2024

@LucioFranco This new trait bound broke my code because hyper::client:ResponseFuture is not Sync.

error[E0277]: `(dyn core::future::future::Future<Output = std::result::Result<http::response::Response<hyper::body::body::Body>, hyper::error::Error>> + std::marker::Send + 'static)` cannot be shared between threads safely
   --> src/lib.rs:153:26
    |
153 |         Ok(Response::new(Box::pin(outbound)
    |                          ^^^^^^^^^^^^^^^^^^ `(dyn core::future::future::Future<Output = std::result::Result<http::response::Response<hyper::body::body::Body>, hyper::error::Error>> + std::marker::Send + 'static)` cannot be shared between threads safely

Still looking into a way to resolve this... Does hyper need to be patched to add the trait bound to ResponseFuture? Or can I wrap this future in something to make it Sync, like futures::lock::Mutex?

cc @seanmonstar Maybe you can help out here?

from tonic.

LucioFranco avatar LucioFranco commented on July 30, 2024

@parasyte maybe I'm missing something but what is the reason you are returning a future as the response type?

from tonic.

parasyte avatar parasyte commented on July 30, 2024

@LucioFranco Sorry for the confusion, I'm not returning Future as a response type at all. It will help to have a full example to the issue. I'll get to that for you soon.

The short description is that I'm calling the get method on a hyper::client::Client in an async_stream::try_stream! {} loop; the return type is a gRPC streaming response. E.g. Pin<Box<dyn Stream<Item = Result<Message, Status> + Send + Sync + 'static>>

Awaiting this non-Sync ResponseFuture from the hyper client (and adding the necessary Sync bound to my streaming response type) is what causes the compile error.

from tonic.

seanmonstar avatar seanmonstar commented on July 30, 2024

Hrm, is the problem that hyper::client::ResponseFuture has a Box<dyn Future + Send> inside it, and not Box<dyn Future + Send + Sync>?

Oh wait, is this because it technically needs a Sync because of await being a jerk?

from tonic.

parasyte avatar parasyte commented on July 30, 2024

@seanmonstar More info in #117 Yes, I think it has to do with await seeing the Sync trait bound and expecting everything to be Sync

from tonic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.