Skip to content
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

New asyncio implementation #1332

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add new asyncio-based implementation.
  • Loading branch information
aaugustin committed Feb 11, 2024
commit a09fce7e3ed5289c1bbc863d4c21e2f656cee819
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
Loading