Classes | |
| class | DummyExecutor |
| class | Future |
| class | ReturnValueIgnoredError |
Functions | |
| def | chain_future |
| def | is_future |
| def | return_future |
| def | run_on_executor |
Variables | |
| tuple | _NO_RESULT = object() |
| tuple | dummy_executor = DummyExecutor() |
| futures = None | |
| FUTURES = Future | |
| TracebackFuture = Future | |
| def tornado.concurrent.chain_future | ( | a, | |
| b | |||
| ) |
Chain two futures together so that when one completes, so does the other. The result (success or failure) of ``a`` will be copied to ``b``, unless ``b`` has already been completed or cancelled by the time ``a`` finishes.
Definition at line 312 of file concurrent.py.
| def tornado.concurrent.is_future | ( | x | ) |
Definition at line 188 of file concurrent.py.
| def tornado.concurrent.return_future | ( | f | ) |
Decorator to make a function that returns via callback return a
`Future`.
The wrapped function should take a ``callback`` keyword argument
and invoke it with one argument when it has finished. To signal failure,
the function can simply raise an exception (which will be
captured by the `.StackContext` and passed along to the ``Future``).
From the caller's perspective, the callback argument is optional.
If one is given, it will be invoked when the function is complete
with `Future.result()` as an argument. If the function fails, the
callback will not be run and an exception will be raised into the
surrounding `.StackContext`.
If no callback is given, the caller should use the ``Future`` to
wait for the function to complete (perhaps by yielding it in a
`.gen.engine` function, or passing it to `.IOLoop.add_future`).
Usage::
@return_future
def future_func(arg1, arg2, callback):
# Do stuff (possibly asynchronous)
callback(result)
@gen.engine
def caller(callback):
yield future_func(arg1, arg2)
callback()
Note that ``@return_future`` and ``@gen.engine`` can be applied to the
same function, provided ``@return_future`` appears first. However,
consider using ``@gen.coroutine`` instead of this combination.
Definition at line 230 of file concurrent.py.
| def tornado.concurrent.run_on_executor | ( | fn | ) |
Decorator to run a synchronous method asynchronously on an executor. The decorated method may be called with a ``callback`` keyword argument and returns a future. This decorator should be used only on methods of objects with attributes ``executor`` and ``io_loop``.
Definition at line 207 of file concurrent.py.
| tuple tornado::concurrent::_NO_RESULT = object() |
Definition at line 227 of file concurrent.py.
Definition at line 204 of file concurrent.py.
| tornado::concurrent::futures = None |
Definition at line 36 of file concurrent.py.
| tuple tornado::concurrent::FUTURES = Future |
Definition at line 183 of file concurrent.py.
Definition at line 180 of file concurrent.py.