Hello friends,
The native websockets branch that I've been puttering with is now available for
review, so I'm asking for someone to review it:
https://github.com/twisted/twisted/pull/12397/files
I'm excited to get this landed and released. WebSockets are probably the most
popular and common form of bidirectional asynchronous communication happening
on the internet today, and it's been a bit of a weakness that we don't have a
simple showcase for that in Twisted. IMAP and SSH are great to have, but
they're not the first thing people go looking for these days when they're
looking to do something async.
We have of course had some access to the WebSockets world via Autobahn, but
first-party integration will have some significant advantages:
We can put a WebSockets example onto our minimal-examples showcase on
twisted.org, because the example is similarly very small, and now included with
no imports from other libraries. This is the major thing; a dozen or so lines
of code illustrating how to push data from Twisted into a browser that a user
can immediately interact with is an important missing piece of the pitch of
Twisted both as a library and as a web server.
There will be a much simpler onboarding experience to this functionality.
Autobahn is still there for anyone who wants WAMP or XBR, but users won't be
presented with those confusing concepts when just trying to do simple
server-side push.
Since the gross private API internals that we rely upon are our own, we don't
have the version-skew problems that Autobahn does
<https://github.com/crossbario/autobahn-python/blob/7bc85b34e200640ab98a41cfddb38267f39bc92e/autobahn/twisted/resource.py#L146-L169>,
nor do we need overhead like anyio.
Since this is a much more recent implementation it also comes with modern
niceties like coroutines rather than inlineCallbacks, comprehensive type
annotations, and 100% code coverage.
This should also be a pretty easy layup of a review:
There is full code coverage and I believe full public API documentation
coverage.
There's new narrative documentation
<https://twisted--12397.org.readthedocs.build/en/12397/web/howto/web-in-60/websockets.html>
explaining how to use it.
The protocol implementation itself is delegated to the existing, minimal,
sans-io wsproto library <https://github.com/python-hyper/wsproto> so there's
not a lot of protocol implementation stuff to review.
The tests are all the new, good kind (i.e.: no native sockets, no real
reactors), using IOPump (and improving that infrastructure a bit as I passed
through it), with (hopefully!) no new flakiness or weird slowdowns.
The downside is that it is brushing up against 1500 changed lines, with most of
that being additions, so it is on the longer side.
Thanks in advance for volunteering,
-g
_______________________________________________
Twisted mailing list -- twisted@python.org
To unsubscribe send an email to twisted-le...@python.org
https://mail.python.org/mailman3/lists/twisted.python.org/
Message archived at
https://mail.python.org/archives/list/twisted@python.org/message/JHHAZXS5ESQGUQEW3EOIKHPW7Q7HJL5V/
Code of Conduct: https://twisted.org/conduct