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 #6

Closed
wants to merge 1 commit into from

Conversation

pyup-bot
Copy link
Collaborator

This PR updates websockets from 5.0.1 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.

6.0

...

.. warning::

 **Version 6.0 introduces the** :class:`~http.Headers` **class for managing
 HTTP headers and changes several public APIs:**

 * :meth:`~server.WebSocketServerProtocol.process_request` now receives a
   :class:`~http.Headers` instead of a :class:`~http.client.HTTPMessage` in
   the ``request_headers`` argument.

 * The :attr:`~protocol.WebSocketCommonProtocol.request_headers` and
   :attr:`~protocol.WebSocketCommonProtocol.response_headers` attributes of
   :class:`~protocol.WebSocketCommonProtocol` are :class:`~http.Headers`
   instead of :class:`~http.client.HTTPMessage`.

 * The :attr:`~protocol.WebSocketCommonProtocol.raw_request_headers` and
   :attr:`~protocol.WebSocketCommonProtocol.raw_response_headers`
   attributes of :class:`~protocol.WebSocketCommonProtocol` are removed.
   Use :meth:`~http.Headers.raw_items` instead.

 * Functions defined in the :mod:`~handshake` module now receive
   :class:`~http.Headers` in argument instead of ``get_header`` or
   ``set_header`` functions. This affects libraries that rely on
   low-level APIs.

 * Functions defined in the :mod:`~http` module now return HTTP headers as
   :class:`~http.Headers` instead of lists of ``(name, value)`` pairs.

 Note that :class:`~http.Headers` and :class:`~http.client.HTTPMessage`
 provide similar APIs.

Also:

* Added compatibility with Python 3.7.
Links

@codecov
Copy link

codecov bot commented Nov 12, 2018

Codecov Report

Merging #6 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master       #6   +/-   ##
=======================================
  Coverage   97.29%   97.29%           
=======================================
  Files           8        8           
  Lines          37       37           
=======================================
  Hits           36       36           
  Misses          1        1

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c05572...57b5f38. Read the comment docs.

@unmade unmade closed this Nov 15, 2018
@unmade unmade deleted the pyup-update-websockets-5.0.1-to-7.0 branch November 15, 2018 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants