Public Member Functions | |
def | __init__ |
def | add_done_callback |
def | cancel |
def | cancelled |
def | done |
def | exc_info |
def | exception |
def | result |
def | running |
def | set_exc_info |
def | set_exception |
def | set_result |
Private Member Functions | |
def | _check_done |
def | _set_done |
Private Attributes | |
_callbacks | |
_done | |
_exc_info | |
_exception | |
_result |
Placeholder for an asynchronous result. A ``Future`` encapsulates the result of an asynchronous operation. In synchronous applications ``Futures`` are used to wait for the result from a thread or process pool; in Tornado they are normally used with `.IOLoop.add_future` or by yielding them in a `.gen.coroutine`. `tornado.concurrent.Future` is similar to `concurrent.futures.Future`, but not thread-safe (and therefore faster for use with single-threaded event loops). In addition to ``exception`` and ``set_exception``, methods ``exc_info`` and ``set_exc_info`` are supported to capture tracebacks in Python 2. The traceback is automatically available in Python 3, but in the Python 2 futures backport this information is discarded. This functionality was previously available in a separate class ``TracebackFuture``, which is now a deprecated alias for this class. .. versionchanged:: 4.0 `tornado.concurrent.Future` is always a thread-unsafe ``Future`` with support for the ``exc_info`` methods. Previously it would be an alias for the thread-safe `concurrent.futures.Future` if that package was available and fall back to the thread-unsafe implementation if it was not.
Definition at line 43 of file concurrent.py.
def tornado.concurrent.Future.__init__ | ( | self | ) |
Definition at line 71 of file concurrent.py.
def tornado.concurrent.Future._check_done | ( | self | ) | [private] |
Definition at line 169 of file concurrent.py.
def tornado.concurrent.Future._set_done | ( | self | ) | [private] |
Definition at line 173 of file concurrent.py.
def tornado.concurrent.Future.add_done_callback | ( | self, | |
fn | |||
) |
Attaches the given callback to the `Future`. It will be invoked with the `Future` as its argument when the Future has finished running and its result is available. In Tornado consider using `.IOLoop.add_future` instead of calling `add_done_callback` directly.
Definition at line 125 of file concurrent.py.
def tornado.concurrent.Future.cancel | ( | self | ) |
Cancel the operation, if possible. Tornado ``Futures`` do not support cancellation, so this method always returns False.
Definition at line 78 of file concurrent.py.
def tornado.concurrent.Future.cancelled | ( | self | ) |
Returns True if the operation has been cancelled. Tornado ``Futures`` do not support cancellation, so this method always returns False.
Definition at line 86 of file concurrent.py.
def tornado.concurrent.Future.done | ( | self | ) |
Returns True if the future has finished running.
Definition at line 98 of file concurrent.py.
def tornado.concurrent.Future.exc_info | ( | self | ) |
Returns a tuple in the same format as `sys.exc_info` or None. .. versionadded:: 4.0
Definition at line 152 of file concurrent.py.
def tornado.concurrent.Future.exception | ( | self, | |
timeout = None |
|||
) |
If the operation raised an exception, return the `Exception` object. Otherwise returns None.
Definition at line 115 of file concurrent.py.
def tornado.concurrent.Future.result | ( | self, | |
timeout = None |
|||
) |
If the operation succeeded, return its result. If it failed, re-raise its exception.
Definition at line 102 of file concurrent.py.
def tornado.concurrent.Future.running | ( | self | ) |
Returns True if this operation is currently running.
Definition at line 94 of file concurrent.py.
def tornado.concurrent.Future.set_exc_info | ( | self, | |
exc_info | |||
) |
Sets the exception information of a ``Future.`` Preserves tracebacks on Python 2. .. versionadded:: 4.0
Definition at line 159 of file concurrent.py.
def tornado.concurrent.Future.set_exception | ( | self, | |
exception | |||
) |
Sets the exception of a ``Future.``
Definition at line 147 of file concurrent.py.
def tornado.concurrent.Future.set_result | ( | self, | |
result | |||
) |
Sets the result of a ``Future``. It is undefined to call any of the ``set`` methods more than once on the same object.
Definition at line 138 of file concurrent.py.
tornado::concurrent.Future::_callbacks [private] |
Definition at line 71 of file concurrent.py.
tornado::concurrent.Future::_done [private] |
Definition at line 71 of file concurrent.py.
tornado::concurrent.Future::_exc_info [private] |
Definition at line 71 of file concurrent.py.
tornado::concurrent.Future::_exception [private] |
Definition at line 71 of file concurrent.py.
tornado::concurrent.Future::_result [private] |
Definition at line 71 of file concurrent.py.