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

asyncio.Handle

Prev: asyncio.get_running_loop | Up: asyncio | Next: asyncio.IncompleteReadError
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.Handle
Tags: #public #python3 #stdlib #asyncio


Import

import asyncio
from asyncio import Handle

Signature & Overview

asyncio.Handle(callback, args, loop, context=None)

Object returned by callback registration methods.

Methods & Attributes

Usage

import asyncio

async def main():
    loop = asyncio.get_running_loop()
    called: list[str] = []
    h = loop.call_soon(called.append, "ran")
    assert isinstance(h, asyncio.Handle)
    await asyncio.sleep(0)
    assert called == ["ran"]

asyncio.run(main())

Gotchas

REPL Inspect

from asyncio import Handle
help(Handle)

Linked from

Related notes