💾 Archived View for tris.fyi › pydoc › asyncio.futures captured on 2022-03-01 at 16:06:46. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-01-08)

➡️ Next capture (2022-07-16)

-=-=-=-=-=-=-

Back to module index

Go to module by name

asyncio

asyncio.futures

A Future class similar to the one in PEP 3148.

Classes

Future

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.
add_done_callback(...)

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

  The callback is called with a single argument - the future object. If
  the future is already done when this is called, the callback is
  scheduled with call_soon.
cancel(self, /, msg=None)

  Cancel the future and schedule callbacks.

  If the future is already done or cancelled, return False.  Otherwise,
  change the future's state to cancelled, schedule the callbacks and
  return True.
cancelled(self, /)

  Return True if the future was cancelled.
done(self, /)

  Return True if the future is done.

  Done means either that a result / exception are available, or that the
  future was cancelled.
exception(self, /)

  Return the exception that was set on this future.

  The exception (or None if no exception was set) is returned only if
  the future is done.  If the future has been cancelled, raises
  CancelledError.  If the future isn't done yet, raises
  InvalidStateError.
get_loop(self, /)

  Return the event loop the Future is bound to.
remove_done_callback(self, fn, /)

  Remove all instances of a callback from the "call when done" list.

  Returns the number of callbacks removed.
result(self, /)

  Return the result this future represents.

  If the future has been cancelled, raises CancelledError.  If the
  future's result isn't yet available, raises InvalidStateError.  If
  the future is done and has an exception set, this exception is raised.
set_exception(self, exception, /)

  Mark the future done and set an exception.

  If the future is already done when this method is called, raises
  InvalidStateError.
set_result(self, result, /)

  Mark the future done and set its result.

  If the future is already done when this method is called, raises
  InvalidStateError.

Functions

isfuture

isfuture(obj)

  Check for a Future.

      This returns True when obj is a Future instance or is advertising
      itself as duck-type compatible by setting _asyncio_future_blocking.
      See comment in Future for more details.
    

wrap_future

wrap_future(future, *, loop=None)

  Wrap concurrent.futures.Future object.

Other members

STACK_DEBUG = 9

Modules

base_futures

concurrent

contextvars

events

exceptions

format_helpers

logging

sys