List currently active tasks in the running loop.
Section: Debugging and Introspection
Inspect running tasks
python
python
import asyncio
async def sleeper():
await asyncio.sleep(1)
async def main():
task = asyncio.create_task(sleeper(), name="demo-task")
for t in asyncio.all_tasks():
print(t.get_name())
await task
asyncio.run(main())Explanation
Use task introspection when debugging leaked or stuck coroutines.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Debugging and Introspection