Skip to content

Commit

Permalink
Add new asyncio-based implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
aaugustin committed Feb 11, 2024
1 parent 61b44cc commit a09fce7
Show file tree
Hide file tree
Showing 18 changed files with 2,977 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tests:
python -m unittest

coverage:
coverage run --source src/websockets,tests -m unittest
coverage run --source src/websockets,tests -m unittest tests/asyncio/test_*.py
coverage html
coverage report --show-missing --fail-under=100

Expand Down
12 changes: 12 additions & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ clients concurrently.
asyncio/server
asyncio/client

:mod:`asyncio` (new)
--------------------

This is a rewrite of the :mod:`asyncio` implementation. It will become the
default implementation.

.. toctree::
:titlesonly:

new-asyncio/server
new-asyncio/client

:mod:`threading`
----------------

Expand Down
51 changes: 51 additions & 0 deletions docs/reference/new-asyncio/client.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Client (:mod:`asyncio` - new)
=============================

.. automodule:: websockets.asyncio.client

Opening a connection
--------------------

.. autofunction:: connect
:async:

.. autofunction:: unix_connect
:async:

Using a connection
------------------

.. autoclass:: ClientConnection

.. automethod:: __aiter__

.. automethod:: recv

.. automethod:: recv_streaming

.. automethod:: send

.. automethod:: close

.. automethod:: ping

.. automethod:: pong

WebSocket connection objects also provide these attributes:

.. autoattribute:: id

.. autoattribute:: logger

.. autoproperty:: local_address

.. autoproperty:: remote_address

The following attributes are available after the opening handshake,
once the WebSocket connection is open:

.. autoattribute:: request

.. autoattribute:: response

.. autoproperty:: subprotocol
41 changes: 41 additions & 0 deletions docs/reference/new-asyncio/common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
:orphan:

Both sides (:mod:`asyncio` - new)
=================================

.. automodule:: websockets.asyncio.connection

.. autoclass:: Connection

.. automethod:: __aiter__

.. automethod:: recv

.. automethod:: recv_streaming

.. automethod:: send

.. automethod:: close

.. automethod:: ping

.. automethod:: pong

WebSocket connection objects also provide these attributes:

.. autoattribute:: id

.. autoattribute:: logger

.. autoproperty:: local_address

.. autoproperty:: remote_address

The following attributes are available after the opening handshake,
once the WebSocket connection is open:

.. autoattribute:: request

.. autoattribute:: response

.. autoproperty:: subprotocol
62 changes: 62 additions & 0 deletions docs/reference/new-asyncio/server.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Server (:mod:`asyncio` - new)
=============================

.. automodule:: websockets.asyncio.server

.. Creating a server
.. -----------------
.. .. autofunction:: serve
.. :async:
.. .. autofunction:: unix_serve
.. :async:
.. Running a server
.. ----------------
.. .. autoclass:: WebSocketServer
.. .. automethod:: serve_forever
.. .. automethod:: shutdown
.. .. automethod:: fileno
Using a connection
------------------

.. autoclass:: ServerConnection

.. automethod:: __aiter__

.. automethod:: recv

.. automethod:: recv_streaming

.. automethod:: send

.. automethod:: close

.. automethod:: ping

.. automethod:: pong

WebSocket connection objects also provide these attributes:

.. autoattribute:: id

.. autoattribute:: logger

.. autoproperty:: local_address

.. autoproperty:: remote_address

The following attributes are available after the opening handshake,
once the WebSocket connection is open:

.. autoattribute:: request

.. autoattribute:: response

.. autoproperty:: subprotocol
Loading

0 comments on commit a09fce7

Please sign in to comment.