25. Asyncio Tasks
Tasks wrap coroutines and run them concurrently.
Example
import asyncio
async def worker(n):
await asyncio.sleep(1)
print(f"Worker {n}")
async def main():
tasks = [asyncio.create_task(worker(i)) for i in range(3)]
await asyncio.gather(*tasks)
asyncio.run(main())
Wrap-Up
Tasks allow multiple coroutines to run concurrently in asyncio.