Copilot Explains: Async/Await in Python



Copilot Explains: Async/Await in Python

Copilot Explains: Async/Await in Python

In this video, Pamela Fox demos Async and Await in Python, and uses #copilot to assist in explaining.

Follow along: https://aka.ms/async_video_code

Chapters:
00:11 Introduction
1:05 Calling the OpenAI Chat Completions API
1:54 Error: coroutine was never awaited
2:54 Copilot explains: What is a coroutine function?
3:30 Error: Await statement is outside of a function
3:52 Copilot fixes by wrapping await call with asyncio.run()
4:37 Successful call to async Chat Completions API
5:04 What’s the benefit of async?
5:36 Copilot explains: How to call multiple async coroutines concurrently?
6:10 Copilot codes multiple calls using asyncio.gather()
6:40 Visualizing order of concurrent coroutines
8:08 Writing async web apps using FastAPI
8:22 Copilot creates a workspace to make FastAPI template
9:07 Exploring the FastAPI workspace
9:14 Conclusion & next steps
9:33 Using asyncio.TaskGroup for concurrent calls