Skip to content

Calling from tokio context #520

Open

Description

@capacman

Hi,
Sorry for if the question is too newbie but is it ok to call functions from a tokio context? like below (tx is streamingcallsink and rx is Clientcstreamreceiver)

tx.feed((data.clone(), WriteFlags::default())).await
rx.await?

Thanks in advance...

Activity

  1. BusyJay commented on Mar 30, 2021

    @BusyJay
    Member

    Yes, it's OK to do so.

  2. capacman commented on Mar 30, 2021

    @capacman
    Author

    Thank you. When i read other issues ,it confuse me a little bit. So what is the problem described in #338

  3. BusyJay commented on Mar 30, 2021

    @BusyJay
    Member

    It's unsafe to mix using different runtime. The problem is that tokio expects using its own executor for their futures. You should not spawn futures calling tokio functions into grpcio by client.spawn or ctx.spawn.

  4. BusyJay commented on Mar 30, 2021

    @BusyJay
    Member

    It's best to bridge them by using some channels and spawn the futures generated by grpcio into grpcio reactor for best performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions