@@ -39,7 +39,7 @@ decorator.
3939
4040Native coroutines are the recommended form whenever possible. Only use
4141decorated coroutines when compatibility with older versions of Python
42- is required. Examples in the tornado documentation will generally use
42+ is required. Examples in the Tornado documentation will generally use
4343the native form.
4444
4545Translation between the two forms is generally straightforward::
@@ -58,30 +58,35 @@ Translation between the two forms is generally straightforward::
5858 # special exception. # Return normally
5959 raise gen.Return(b) return b
6060
61- Other differences between the two forms of coroutine are:
62-
63- - Native coroutines are generally faster.
64- - Native coroutines can use ``async for `` and ``async with ``
65- statements which make some patterns much simpler.
66- - Native coroutines do not run at all unless you ``await `` or
67- ``yield `` them. Decorated coroutines can start running "in the
68- background" as soon as they are called. Note that for both kinds of
69- coroutines it is important to use ``await `` or ``yield `` so that
70- any exceptions have somewhere to go.
71- - Decorated coroutines have additional integration with the
72- `concurrent.futures ` package, allowing the result of
73- ``executor.submit `` to be yielded directly. For native coroutines,
74- use `.IOLoop.run_in_executor ` instead.
75- - Decorated coroutines support some shorthand for waiting on multiple
76- objects by yielding a list or dict. Use `tornado.gen.multi ` to do
77- this in native coroutines.
78- - Decorated coroutines can support integration with other packages
79- including Twisted via a registry of conversion functions.
80- To access this functionality in native coroutines, use
81- `tornado.gen.convert_yielded `.
82- - Decorated coroutines always return a `.Future ` object. Native
83- coroutines return an *awaitable * object that is not a `.Future `. In
84- Tornado the two are mostly interchangeable.
61+ Other differences between the two forms of coroutine are outlined below.
62+
63+ - Native coroutines:
64+
65+ - are generally faster.
66+ - can use ``async for `` and ``async with ``
67+ statements which make some patterns much simpler.
68+ - do not run at all unless you ``await `` or
69+ ``yield `` them. Decorated coroutines can start running "in the
70+ background" as soon as they are called. Note that for both kinds of
71+ coroutines it is important to use ``await `` or ``yield `` so that
72+ any exceptions have somewhere to go.
73+
74+ - Decorated coroutines:
75+
76+ - have additional integration with the
77+ `concurrent.futures ` package, allowing the result of
78+ ``executor.submit `` to be yielded directly. For native coroutines,
79+ use `.IOLoop.run_in_executor ` instead.
80+ - support some shorthand for waiting on multiple
81+ objects by yielding a list or dict. Use `tornado.gen.multi ` to do
82+ this in native coroutines.
83+ - can support integration with other packages
84+ including Twisted via a registry of conversion functions.
85+ To access this functionality in native coroutines, use
86+ `tornado.gen.convert_yielded `.
87+ - always return a `.Future ` object. Native
88+ coroutines return an *awaitable * object that is not a `.Future `. In
89+ Tornado the two are mostly interchangeable.
8590
8691How it works
8792~~~~~~~~~~~~
0 commit comments