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

Calling from tokio context #520

Open
capacman opened this issue Mar 29, 2021 · 4 comments
Open

Calling from tokio context #520

capacman opened this issue Mar 29, 2021 · 4 comments

Comments

@capacman
Copy link

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...

@BusyJay
Copy link
Member

BusyJay commented Mar 30, 2021

Yes, it's OK to do so.

@capacman
Copy link
Author

capacman commented Mar 30, 2021

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

@BusyJay
Copy link
Member

BusyJay commented Mar 30, 2021

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.

@BusyJay
Copy link
Member

BusyJay commented Mar 30, 2021

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants