From 615db3ed3c411d935e24c9560b06210faa1b8bab Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 24 Jan 2015 18:18:09 -0500 Subject: [PATCH] Update release notes and docs. --- docs/gen.rst | 4 ++++ docs/releases/next.rst | 23 +++++++++++++++++++++++ tornado/websocket.py | 17 ++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/gen.rst b/docs/gen.rst index e9a7e5c5..c9d1cc85 100644 --- a/docs/gen.rst +++ b/docs/gen.rst @@ -20,11 +20,15 @@ .. autofunction:: maybe_future + .. autofunction:: sleep + .. autodata:: moment :annotation: .. autofunction:: Task + .. autoclass:: WaitIterator + .. class:: Arguments The result of a `Task` or `Wait` whose callback had more than one diff --git a/docs/releases/next.rst b/docs/releases/next.rst index 9c03893e..751aec58 100644 --- a/docs/releases/next.rst +++ b/docs/releases/next.rst @@ -87,3 +87,26 @@ In progress * Malformed ``multipart/form-data`` bodies will always be logged quietly instead of raising an unhandled exception; previously the behavior was inconsistent depending on the exact error. +* `.websocket_connect` now has a ``on_message_callback`` keyword argument + for callback-style use without ``read_message()``. +* New class `tornado.gen.WaitIterator` provides a way to iterate + over ``Futures`` in the order they resolve. +* When a new `.IOLoop` is created, it automatically becomes "current" + for the thread if there is not already a current instance. +* When the `~functools.singledispatch` library is available (standard on + Python 3.4, available via ``pip install singledispatch`` on older versions), + the `.convert_yielded` function can be used to make other kinds of objects + yieldable in coroutines. +* It is now possible to yield ``asyncio.Future`` objects in coroutines + when the `~functools.singledispatch` library is available and + ``tornado.platform.asyncio`` has been imported. +* It is now possible to yield ``Deferred`` objects in coroutines + when the `~functools.singledispatch` library is available and + ``tornado.platform.twisted`` has been imported. +* New methods `tornado.platform.asyncio.to_tornado_future` and + `~tornado.platform.asyncio.to_asyncio_future` convert between + the two libraries' `.Future` classes. +* New function `tornado.gen.sleep` is a coroutine-friendly + analogue to `time.sleep`. +* ``tornado.curl_httpclient`` now uses its own logger for debug output + so it can be filtered more easily. diff --git a/tornado/websocket.py b/tornado/websocket.py index ccf80f46..c009225c 100644 --- a/tornado/websocket.py +++ b/tornado/websocket.py @@ -1000,11 +1000,26 @@ def websocket_connect(url, io_loop=None, callback=None, connect_timeout=None, ``compression_options`` is interpreted in the same way as the return value of `.WebSocketHandler.get_compression_options`. + The connection supports two styles of operation. In the coroutine + style, the application typically calls + `~.WebSocketClientConnection.read_message` in a loop:: + + conn = yield websocket_connection(loop) + while True: + msg = yield conn.read_message() + if msg is None: break + # Do something with msg + + In the callback style, pass an ``on_message_callback`` to + ``websocket_connect``. In both styles, a message of ``None`` + indicates that the connection has been closed. + .. versionchanged:: 3.2 Also accepts ``HTTPRequest`` objects in place of urls. .. versionchanged:: 4.1 - Added ``compression_options``. The ``io_loop`` argument is deprecated. + Added ``compression_options`` and ``on_message_callback``. + The ``io_loop`` argument is deprecated. """ if io_loop is None: io_loop = IOLoop.current()