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

Update websockets to 7.0 #431

Merged
merged 1 commit into from
Nov 30, 2018
Merged

Conversation

pyup-bot
Copy link
Collaborator

@pyup-bot pyup-bot commented Nov 1, 2018

This PR updates websockets from 6.0 to 7.0.

Changelog

7.0

...

.. warning::

 **Version 7.0 renames the** ``timeout`` **argument of**
 :func:`~server.serve()` **and** :func:`~client.connect()` **to**
 ``close_timeout`` **.**

 This prevents confusion with ``ping_timeout``.

 For backwards compatibility, ``timeout`` is still supported.

.. warning::

 **Version 7.0 changes how a server terminates connections when it's
 closed with :meth:`~websockets.server.WebSocketServer.close`.**

 Previously, connections handlers were canceled. Now, connections are
 closed with close code 1001 (going away). From the perspective of the
 connection handler, this is the same as if the remote endpoint was
 disconnecting. This removes the need to prepare for
 :exc:`~asyncio.CancelledError` in connection handlers.

 You can restore the previous behavior by adding the following line at the
 beginning of connection handlers::

     def handler(websocket, path):
         closed = asyncio.ensure_future(websocket.wait_closed())
         closed.add_done_callback(lambda task: task.cancel())

.. warning::

 **Version 7.0 changes how a** :meth:`~protocol.WebSocketCommonProtocol.ping`
 **that hasn't received a pong yet behaves when the connection is closed.**

 The ping — as in ``ping = await websocket.ping()`` — used to be canceled
 when the connection is closed, so that ``await ping`` raised
 :exc:`~asyncio.CancelledError`. Now ``await ping`` raises
 :exc:`~exceptions.ConnectionClosed` like other public APIs.

.. warning::

 **Version 7.0 raises a** :exc:`RuntimeError` **exception if two coroutines
 call** :meth:`~protocol.WebSocketCommonProtocol.recv` **concurrently.**

 Concurrent calls lead to non-deterministic behavior because there are no
 guarantees about which coroutine will receive which message.

Also:

* websockets sends Ping frames at regular intervals and closes the connection
if it doesn't receive a matching Pong frame. See
:class:`~protocol.WebSocketCommonProtocol` for details.

* Added ``process_request`` and ``select_subprotocol`` arguments to
:func:`~server.serve()` and :class:`~server.WebSocketServerProtocol` to
customize :meth:`~server.WebSocketServerProtocol.process_request` and
:meth:`~server.WebSocketServerProtocol.select_subprotocol` without
subclassing :class:`~server.WebSocketServerProtocol`

* Added support for sending fragmented messages.

* Added the :meth:`~protocol.WebSocketCommonProtocol.wait_closed` method to
protocols.

* Added an interactive client: ``python -m websockets <uri>``.

* Changed the ``origins`` argument to represent the lack of an origin with
``None`` rather than ``''``.

* Fixed a data loss bug in :meth:`~protocol.WebSocketCommonProtocol.recv`:
canceling it at the wrong time could result in messages being dropped.

* Improved handling of multiple HTTP headers with the same name.

* Improved error messages when a required HTTP header is missing.
Links

Resolves #432

@Harmon758 Harmon758 merged commit cbc2f90 into rewrite Nov 30, 2018
@Harmon758 Harmon758 deleted the pyup-update-websockets-6.0-to-7.0 branch November 30, 2018 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

websockets versions available: 7.0
2 participants