Lines Matching full: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
68 .. function:: wrap_future(future, *, loop=None)
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
88 set, or until they are cancelled. A Future can be awaited multiple
96 The rule of thumb is to never expose Future objects in user-facing
97 APIs, and the recommended way to create a Future object is to call
100 of a Future object.
111 Return the result of the Future.
113 If the Future is *done* and has a result set by the
116 If the Future is *done* and has an exception set by the
119 If the Future has been *cancelled*, this method raises
122 If the Future's result isn't yet available, this method raises
127 Mark the Future as *done* and set its result.
129 Raises a :exc:`InvalidStateError` error if the Future is
134 Mark the Future as *done* and set an exception.
136 Raises a :exc:`InvalidStateError` error if the Future is
141 Return ``True`` if the Future is *done*.
143 A Future is *done* if it was *cancelled* or if it has a result
149 Return ``True`` if the Future was *cancelled*.
151 The method is usually used to check if a Future is not
159 Add a callback to be run when the Future is *done*.
161 The *callback* is called with the Future object as its only
164 If the Future is already *done* when this method is called,
174 # Call 'print("Future:", fut)' when "fut" is done.
176 functools.partial(print, "Future:"))
191 Cancel the Future and schedule callbacks.
193 If the Future is already *done* or *cancelled*, return ``False``.
194 Otherwise, change the Future's state to *cancelled*,
202 Return the exception that was set on this Future.
205 returned only if the Future is *done*.
207 If the Future has been *cancelled*, this method raises a
210 If the Future isn't *done* yet, this method raises an
215 Return the event loop the Future object is bound to.
222 This example creates a Future object, creates and schedules an
223 asynchronous Task to set result for the Future, and waits until
224 the Future has a result::
230 # Set *value* as a result of *fut* Future.
237 # Create a new Future object.
257 The Future object was designed to mimic
258 :class:`concurrent.futures.Future`. Key differences include:
260 - unlike asyncio Futures, :class:`concurrent.futures.Future`
263 - :meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception`
266 - :meth:`asyncio.Future.result` and :meth:`asyncio.Future.exception`
267 raise an :exc:`InvalidStateError` exception when the Future is not
270 - Callbacks registered with :meth:`asyncio.Future.add_done_callback`
274 - asyncio Future is not compatible with the
278 - :meth:`asyncio.Future.cancel` accepts an optional ``msg`` argument,