-
Notifications
You must be signed in to change notification settings - Fork 15
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
[Discussion] Make integrations with asyncio projects more friendly #10
Comments
Let me throw out an idea I've been toying around with in my mind.... One of the big ideas in Curio was that of keeping the underlying kernel pretty well isolated from everything else. I did some experiments with writing a kernel purely in C (which worked). It might not be too hard to write a Curio kernel that was implemented entirely on top of asyncio. Maybe it's possible to have some kind of better asyncio interop through that kind of approach. The idea is that you would have the same high-level Curio programming API that it has now--it'd just be running natively on top of asyncio. Thoughts? |
Aren't we gonna get async/await-native API on top of plain old callback API? Surely it's just jumps and system calls from assembler perspective, and OS does not care anyway, but I wonder if there might be any hidden buffers (e.g. for the sake of non-blocking |
Hey, I hadn't see this before but it's a neat project! Thanks for CC'ing me :-).
You'll probably have some issues with
One caveat to watch out for is that with
We've tried to figure out how to do this in trio-asyncio, but it's really hard :-(. The two worlds are pretty different, especially in their cancellation semantics. Also a lot of libraries (like aiohttp) are really fond of doing things like
👋 If you're interested then we'd certainly be happy to help you figure that out (and I think there are probably several people who would be excited about a grpc implementation for trio!). If you have questions then we have a pretty active chat channel. Alternatively: You might also want to look at @agronholm's anyio, which provides a mostly-trio-ish API on top of asyncio/curio/trio. There are two major things to be aware of I think, but they probably won't bother you:
Also, using anyio does risk that you might be a bit foreign-feeling everywhere; e.g. Trio has a standard interface for streaming messages, and Trio users will probably expect a grpc API to use this for streaming RPCs? But this is probably not the biggest issue on your plate right now... |
@njsmith thanks for the thorough reply! I've decided to try @agronholm's anyio library and to my surprise migration went almost seamless. My work is in P.S. I've encountered a bug in anyio's |
@standy66 I only read this after I fixed the bug. If you are in a hurry for a new release, I can do that. Otherwise I'll first have a go at fixing agronholm/anyio#37. |
@agronholm Nah, I think I'll be fine if the current workaround stayed for some time. After all, I am already monkey patching some stuff in h2 state machine so it behaves itself correctly when communicating with gRPC Core peers. |
Merged #13 |
Right now purerpc uses curio event loop, which is really pleasant to use (thx @dabeaz) but limits interoperability with other asyncio projects. Curio was chosen in 2017 mainly because of this @njsmith's post. As of 2019, some things changed:
The text was updated successfully, but these errors were encountered: