PyDocs

Nav

Networking and Interprocess Communication

Future

asyncio

classDeprecated 3.10not WASI
  • Future(*, loop=None)
Deprecated since 3.10. Deprecation warning is emitted if loop is not specified and there is no running event loop.
This class is *almost* compatible with concurrent.futures.Future.

Differences:

- result() and exception() do not take a timeout argument and
  raise an exception when the future isn't done yet.

- Callbacks registered with add_done_callback() are always called
  via the event loop's call_soon_threadsafe().

- This class is not compatible with the wait() and as_completed()
  methods in the concurrent.futures package.
Changed in 3.7
  • 3.7: Added support for the contextvars module.
Members of Future

_

__init__
Initialize self.

a

add_done_callback
Add a callback to be run when the future becomes done.

c

cancel
Cancel the future and schedule callbacks.
cancelled
Return True if the future was cancelled.

d

done
Return True if the future is done.

e

exception
Return the exception that was set on this future.

g

get_loop
Return the event loop the Future is bound to.

r

remove_done_callback
Remove all instances of a callback from the "call when done" list.
result
Return the result this future represents.

s

set_exception
Mark the future done and set an exception.
set_result
Mark the future done and set its result.
0 Examples
No examples for asyncio/Future.
See Also
No see-alsos for asyncio/Future
0 Notes
No notes for Future