Skip to content

Commit

Permalink
Mention async/await in coroutine docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Aug 2, 2015
1 parent 70e52f9 commit 959da8f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions docs/guide/coroutines.rst
Expand Up @@ -33,6 +33,22 @@ Example::
# instead.
return response.body

Python 3.5: ``async`` and ``await``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Python 3.5 introduces the ``async`` and ``await`` keywords. Starting in
Tornado 4.3, you can use them in place of ``yield``-based coroutines.
Simply use ``async def foo()`` in place of a function definition with the
``@gen.coroutine`` decorator, and ``await`` in place of yield. The rest of
this document still uses the ``yield`` style for compatibility with older
versions of Python, but ``async`` and ``await`` will run faster when they
are available::

async def fetch_coroutine(url):
http_client = AsyncHTTPClient()
response = await http_client.fetch(url)
return response.body

How it works
~~~~~~~~~~~~

Expand Down

0 comments on commit 959da8f

Please sign in to comment.