-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
[WIP] Memory Streams #866
[WIP] Memory Streams #866
Conversation
…e to test network code without using any sockets. tests still blocking...
It seems to be because :
Should we bound memory queues ? |
Hi! Thanks for working on this! Let's start by figuring out what the plan is at a high level. Right now, the idea in this PR seems to be that people will write So, the idea we've been working on is a bit different. Trio has hooks (documented here) that let you override all networking inside a Trio program, in a single step. It works by overriding how Trio's sockets work, so it works for programs that use requests, it works for programs that use Does that make sense? BTW, depending on how complex this is, it might make sense to split it out as a separate library. We don't have to decide that up front, and cookiecutter-trio makes it pretty quick to set up a new library, but it's something to keep in mind. |
Very welcome, I m looking forward the day that I can debug most of my network code without setting up an actual network. Oh interesting... Having network configuration (layout, deploy targets, etc.) as part of the context, definitely makes sense. I ll have a look at how hooks work next, then. At a higher level, I am playing around with trio-protocol, as the I imagine part of the whole feature will be in trio's code, as a generic way to support various abstract, yet related, functionalities, and a specific polished implementation in a separate library. No idea yet of where to draw the line between these two parts however. |
I definitely recommend using the sans-io approach, it's great. (And you'll want to read #796 for more discussion.) But usually when we talk about sans-io, we don't mean asyncio protocols/transports; we mean libraries like h11/h2/wsproto, which use a fairly different API style. And the Trio equivalent of protocols/transports is the Stream API, which is much more friendly to composition than the traditional protocol/transport approach. If you want to see examples of sans-io libraries hooked up to trio, then I'd suggest looking at:
|
I'm going to mark this closed for now b/c it sounds like you're rethinking things, so there isn't anything to review currently. Feel free to re-open after you do, or open a new PR, or whatever makes most sense :-). |
A small step, to ultimately address #170
Exposing memory streams similarly to tcp streams to be able to test network code without using any actual sockets.
Still WIP.
No docs and basic tests (
check_half_closeable_stream
) still blocking around https://github.com/python-trio/trio/blob/master/trio/testing/_check_streams.py#L275