Lines Matching refs:Future
15 *Future* objects are used to bridge **low-level callback-based code**
19 Future Functions
26 * an instance of :class:`asyncio.Future`,
28 * a Future-like object with a ``_asyncio_future_blocking``
38 * *obj* argument as is, if *obj* is a :class:`Future`,
39 a :class:`Task`, or a Future-like object (:func:`isfuture`
64 Deprecation warning is emitted if *obj* is not a Future-like object
70 Wrap a :class:`concurrent.futures.Future` object in a
71 :class:`asyncio.Future` object.
74 Deprecation warning is emitted if *future* is not a Future-like object
78 Future Object
81 .. class:: Future(*, loop=None)
83 A Future represents an eventual result of an asynchronous
86 Future is an :term:`awaitable` object. Coroutines can await on
87 Future objects until they either have a result or an exception
95 The rule of thumb is to never expose Future objects in user-facing
96 APIs, and the recommended way to create a Future object is to call
99 of a Future object.
110 Return the result of the Future.
112 If the Future is *done* and has a result set by the
115 If the Future is *done* and has an exception set by the
118 If the Future has been *cancelled*, this method raises
121 If the Future's result isn't yet available, this method raises
126 Mark the Future as *done* and set its result.
128 Raises a :exc:`InvalidStateError` error if the Future is
133 Mark the Future as *done* and set an exception.
135 Raises a :exc:`InvalidStateError` error if the Future is
140 Return ``True`` if the Future is *done*.
142 A Future is *done* if it was *cancelled* or if it has a result
148 Return ``True`` if the Future was *cancelled*.
150 The method is usually used to check if a Future is not
158 Add a callback to be run when the Future is *done*.
160 The *callback* is called with the Future object as its only
163 If the Future is already *done* when this method is called,
173 # Call 'print("Future:", fut)' when "fut" is done.
175 functools.partial(print, "Future:"))
190 Cancel the Future and schedule callbacks.
192 If the Future is already *done* or *cancelled*, return ``False``.
193 Otherwise, change the Future's state to *cancelled*,
201 Return the exception that was set on this Future.
204 returned only if the Future is *done*.
206 If the Future has been *cancelled*, this method raises a
209 If the Future isn't *done* yet, this method raises an
214 Return the event loop the Future object is bound to.
221 This example creates a Future object, creates and schedules an
222 asynchronous Task to set result for the Future, and waits until
223 the Future has a result::
229 # Set *value* as a result of *fut* Future.
236 # Create a new Future object.
256 The Future object was designed to mimic
257 :class:`concurrent.futures.Future`. Key differences include:
259 - unlike asyncio Futures, :class:`concurrent.futures.Future`
262 - :meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception`
265 - :meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception`
266 raise an :exc:`InvalidStateError` exception when the Future is not
269 - Callbacks registered with :meth:`asyncio.Future.add_done_callback`
273 - asyncio Future is not compatible with the
277 - :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,