Robots Atlas>ROBOTS ATLAS

Python — From Basics to Advanced · Asyncio and Concurrent Programming

Tasks, Cancellation, and Timeouts

Asyncio and Concurrent Programming

Introduction

A Task is a coroutine scheduled in the event loop. asyncio.create_task() runs it in the background — you can then await it, cancel it, wait for it with a timeout, or compose it with others. Cancellation works by raising CancelledError inside the task, and the async with asyncio.TaskGroup() block (3.11+) handles cleanup automatically.