Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

AsyncIO Basics | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 42 of 55

·Python

AsyncIO Basics

20 minutes

Course progress76%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • Define coroutine functions with `async def`.
  • Await asynchronous operations with `await`.
  • `asyncio.gather` runs several coroutines concurrently.
  • Use `asyncio.run(main())` as the entry point.

AsyncIO Basics

asyncio provides the building blocks for asynchronous, non‑blocking code using the async/await syntax. It shines for I/O‑bound workloads like network calls.

import asyncio

async def greet(name):
    await asyncio.sleep(1)  # simulate async I/O
    return f'Hello, {name}!'

async def main():
    messages = await asyncio.gather(greet('Alice'), greet('Bob'))
    for m in messages:
        print(m)

asyncio.run(main())

The event loop (asyncio.run) schedules coroutines and runs them concurrently.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonWorking with APIsContinue to lesson 43Concurrency with threadingBack to Python Fundamentals curriculum