On this page
  1. asyncio.create_eager_task_factory
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

asyncio.create_eager_task_factory

Prev: asyncio.Condition | Up: asyncio | Next: asyncio.create_subprocess_exec
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.create_eager_task_factory
Tags: #public #python3 #stdlib #asyncio


Import

import asyncio
from asyncio import create_eager_task_factory

Signature & Overview

asyncio.create_eager_task_factory(custom_task_constructor)

Create a function suitable for use as a task factory on an event-loop.

Usage

import asyncio

async def main():
    loop = asyncio.get_running_loop()
    factory = asyncio.create_eager_task_factory(asyncio.Task)
    loop.set_task_factory(factory)
    assert await asyncio.create_task(asyncio.sleep(0, result=42)) == 42

asyncio.run(main())

Gotchas

REPL Inspect

from asyncio import create_eager_task_factory
help(create_eager_task_factory)

Linked from

Related notes