2017-12-18 02:47:58 +00:00
|
|
|
``tornado.concurrent`` --- Work with ``Future`` objects
|
|
|
|
=======================================================
|
2013-03-15 03:45:48 +00:00
|
|
|
|
2015-02-09 05:19:47 +00:00
|
|
|
.. testsetup::
|
|
|
|
|
|
|
|
from tornado.concurrent import *
|
|
|
|
from tornado import gen
|
|
|
|
|
2013-03-15 03:45:48 +00:00
|
|
|
.. automodule:: tornado.concurrent
|
|
|
|
:members:
|
2013-03-17 17:42:12 +00:00
|
|
|
|
2017-12-18 02:47:58 +00:00
|
|
|
.. class:: Future
|
2013-03-17 17:42:12 +00:00
|
|
|
|
2017-12-18 02:47:58 +00:00
|
|
|
``tornado.concurrent.Future`` is an alias for `asyncio.Future`
|
|
|
|
on Python 3. On Python 2, it provides an equivalent
|
|
|
|
implementation.
|
2013-03-17 17:42:12 +00:00
|
|
|
|
2017-12-18 02:47:58 +00:00
|
|
|
In Tornado, the main way in which applications interact with
|
|
|
|
``Future`` objects is by ``awaiting`` or ``yielding`` them in
|
|
|
|
coroutines, instead of calling methods on the ``Future`` objects
|
|
|
|
themselves. For more information on the available methods, see
|
|
|
|
the `asyncio.Future` docs.
|
2013-03-17 17:42:12 +00:00
|
|
|
|
2017-12-18 02:47:58 +00:00
|
|
|
.. versionchanged:: 5.0
|
2013-03-17 17:42:12 +00:00
|
|
|
|
2017-12-18 02:47:58 +00:00
|
|
|
Tornado's implementation of ``Future`` has been replaced by
|
|
|
|
the version from `asyncio` when available.
|
|
|
|
|
|
|
|
- ``Future`` objects can only be created while there is a
|
|
|
|
current `.IOLoop`
|
|
|
|
- The timing of callbacks scheduled with
|
|
|
|
``Future.add_done_callback`` has changed.
|
|
|
|
- Cancellation is now partially supported (only on Python 3)
|
|
|
|
- The ``exc_info`` and ``set_exc_info`` methods are no longer
|
|
|
|
available on Python 3.
|