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`
63 Wrap a :class:`concurrent.futures.Future` object in a
64 :class:`asyncio.Future` object.
67 Future Object
70 .. class:: Future(*, loop=None)
72 A Future represents an eventual result of an asynchronous
75 Future is an :term:`awaitable` object. Coroutines can await on
76 Future objects until they either have a result or an exception
84 The rule of thumb is to never expose Future objects in user-facing
85 APIs, and the recommended way to create a Future object is to call
88 of a Future object.
95 Return the result of the Future.
97 If the Future is *done* and has a result set by the
100 If the Future is *done* and has an exception set by the
103 If the Future has been *cancelled*, this method raises
106 If the Future's result isn't yet available, this method raises
111 Mark the Future as *done* and set its result.
113 Raises a :exc:`InvalidStateError` error if the Future is
118 Mark the Future as *done* and set an exception.
120 Raises a :exc:`InvalidStateError` error if the Future is
125 Return ``True`` if the Future is *done*.
127 A Future is *done* if it was *cancelled* or if it has a result
133 Return ``True`` if the Future was *cancelled*.
135 The method is usually used to check if a Future is not
143 Add a callback to be run when the Future is *done*.
145 The *callback* is called with the Future object as its only
148 If the Future is already *done* when this method is called,
158 # Call 'print("Future:", fut)' when "fut" is done.
160 functools.partial(print, "Future:"))
175 Cancel the Future and schedule callbacks.
177 If the Future is already *done* or *cancelled*, return ``False``.
178 Otherwise, change the Future's state to *cancelled*,
186 Return the exception that was set on this Future.
189 returned only if the Future is *done*.
191 If the Future has been *cancelled*, this method raises a
194 If the Future isn't *done* yet, this method raises an
199 Return the event loop the Future object is bound to.
206 This example creates a Future object, creates and schedules an
207 asynchronous Task to set result for the Future, and waits until
208 the Future has a result::
214 # Set *value* as a result of *fut* Future.
221 # Create a new Future object.
241 The Future object was designed to mimic
242 :class:`concurrent.futures.Future`. Key differences include:
244 - unlike asyncio Futures, :class:`concurrent.futures.Future`
247 - :meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception`
250 - :meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception`
251 raise an :exc:`InvalidStateError` exception when the Future is not
254 - Callbacks registered with :meth:`asyncio.Future.add_done_callback`
258 - asyncio Future is not compatible with the
262 - :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,