Skip to content

Commit

Permalink
Document removal of open and closed properties.
Browse files Browse the repository at this point in the history
They won't be added to the new asyncio implementation.
  • Loading branch information
aaugustin committed Aug 17, 2024
1 parent 8d9f9a1 commit 7c8e0b9
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/howto/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,29 @@ buffer now.

The ``write_limit`` argument of :func:`~asyncio.client.connect` and
:func:`~asyncio.server.serve` defaults to 32 KiB instead of 64 KiB.

Attributes of connections
.........................

``open`` and ``closed``
~~~~~~~~~~~~~~~~~~~~~~~

The :attr:`~legacy.protocol.WebSocketCommonProtocol.open` and
:attr:`~legacy.protocol.WebSocketCommonProtocol.closed` properties are removed.
Using them was discouraged.

Instead, you should call :meth:`~asyncio.connection.Connection.recv` or
:meth:`~asyncio.connection.Connection.send` and handle
:exc:`~exceptions.ConnectionClosed` exceptions.

If your code relies on them, you can replace::

connection.open
connection.closed

with::

from websockets.protocol import State

connection.state is State.OPEN
connection.state is State.CLOSED

0 comments on commit 7c8e0b9

Please sign in to comment.