On this page
  1. asyncio.Future
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

asyncio.Future

Prev: asyncio.FrameCallGraphEntry | Up: asyncio | Next: asyncio.future_add_to_awaited_by
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.Future
Tags: #public #python3 #stdlib #asyncio


Import

import asyncio
from asyncio import Future

Signature & Overview

asyncio.Future(*, loop=None)

This class is almost compatible with concurrent.futures.Future.

Methods & Attributes

Usage

import asyncio

async def main():
    loop = asyncio.get_running_loop()
    fut = loop.create_future()
    loop.call_soon(fut.set_result, "resolved")
    assert await fut == "resolved"

asyncio.run(main())

Gotchas

REPL Inspect

from asyncio import Future
help(Future)

Linked from

Related notes