On this page
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
- Raises
RuntimeErrorif no loop is running (whenloop=None).
REPL Inspect
from asyncio import current_task
help(current_task)
Linked from
Related notes
- tuts/python3/stdlib_module/asyncio/create_task Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/DatagramProtocol Linked here; links to this page; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractEventLoop Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/AbstractServer Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/all_tasks Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/as_completed Linked here; shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/Barrier shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseEventLoop shared tags: #asyncio, #stdlib
- tuts/python3/stdlib_module/asyncio/BaseProtocol shared tags: #asyncio, #stdlib