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

asyncio.current_task

Prev: asyncio.create_task | Up: asyncio | Next: asyncio.DatagramProtocol
Rel: asyncio.AbstractEventLoop, asyncio.AbstractServer, asyncio.all_tasks, asyncio.as_completed
Ref: docs.python.org — asyncio.current_task
Tags: #public #python3 #stdlib #asyncio


Import

import asyncio
from asyncio import current_task

Signature & Overview

asyncio.current_task(loop=None)

Return a currently executed task.

Usage

import asyncio

async def main():
    t = asyncio.current_task()
    assert t is not None and isinstance(t, asyncio.Task)

asyncio.run(main())

Gotchas

REPL Inspect

from asyncio import current_task
help(current_task)

Linked from

Related notes