Skip to content

Provide a Sans-I/O interface - #676

Merged
aaugustin merged 15 commits into
masterfrom
sans-i/o
Jul 26, 2020
Merged

aaugustin merged 15 commits into
masterfrom
sans-i/o

Conversation

@aaugustin

Copy link
Copy Markdown
Member

Fix #466.

@codecov

codecov Bot commented Nov 1, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #676 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##            master      #676    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           29        43    +14     
  Lines         4388      4928   +540     
  Branches       406       436    +30     
==========================================
+ Hits          4388      4928   +540     
Impacted Files Coverage Δ
src/websockets/__init__.py 100.00% <100.00%> (ø)
src/websockets/auth.py 100.00% <100.00%> (ø)
src/websockets/client.py 100.00% <100.00%> (ø)
src/websockets/datastructures.py 100.00% <100.00%> (ø)
src/websockets/exceptions.py 100.00% <100.00%> (ø)
src/websockets/extensions/base.py 100.00% <100.00%> (ø)
src/websockets/extensions/permessage_deflate.py 100.00% <100.00%> (ø)
src/websockets/frames.py 100.00% <100.00%> (ø)
src/websockets/framing.py 100.00% <100.00%> (ø)
src/websockets/handshake.py 100.00% <100.00%> (ø)
... and 45 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f0cfa6b...9d5808b. Read the comment docs.

@cjerdonek

Copy link
Copy Markdown
Collaborator

I just finished reading your blog post about this effort. That's a superb writeup! Thanks!

One question I had when reading it: have you thought about whether there's an incremental way to start incorporating Sans I/O elements into your existing (non-Sans I/O) implementation? I'm wondering if it could help address some of the difficulties inherent in a "big bang" switch (as well as the need to maintain a parallel branch of such magnitude).

@aaugustin

Copy link
Copy Markdown
Member Author

Well it's pretty hard to avoid a big bang:

  • I did some preliminary work to remove some asyncio infrastructure, so the WebSocket protocol class is as close as possible to the transport.
  • This PR prepares an entire Sans I/O implementation of the WebSocket protocol.
  • Then at some point there's open-heart surgery to wire them together. I don't know how to avoid this.

@cjerdonek

Copy link
Copy Markdown
Collaborator

Just to clarify, I wasn't asking about the possibility of eliminating a big bang entirely, but rather decreasing the magnitude of the change by incrementally incorporating and using some elements of the Sans I/O implementation prior to completely switching over.

For example, could parts of the implementation be used under the hood without affecting the public-facing API too much? As another example, could the HTTP aspects being added first, prior to the websocket aspects?

@aaugustin

Copy link
Copy Markdown
Member Author

In the PR, there's a lot of "moving + changing await to yield from + refactoring tests" which results in large changes that aren't really new code.

It's quite hard to perform "socket transplantation" i.e. switching a network socket connected to asyncio utilities over to a sans I/O stack, or vice versa. Technically it must be possible (transfer the buffer over if needed) but it's far from trivial.

It was too thin. It didn't add any value. Using the same abstractions
for connection events and wire messages is good enough for our purposes.
In the new model, receive_data returns nothing and raises an exception
on errors. Events received and bytes to send are obtained through other
method calls.
@aaugustin

Copy link
Copy Markdown
Member Author

This PR now contains a fairly complete Sans-I/O implementation of the WebSocket protocol. It doesn't include:

  • porting the asyncio-based implementation on top of this new code — this will take quite a bit of work
  • documentation for the Sans-I/O bits

For all the usual reasons against long running branches with huge changes, I'm planning to merge this now.

@aaugustin
aaugustin merged commit 2074074 into master Jul 26, 2020
@aaugustin
aaugustin deleted the sans-i/o branch May 2, 2021 19:46
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

Successfully merging this pull request may close these issues.

Refactor to introduce a sans-I/O layer?

2 participants