2 asyncio basics
This chapter covers
- The basics of
async
await
syntax and coroutines - Running coroutines concurrently with tasks
- Canceling tasks
- Manually creating the event loop
- Measuring a coroutine’s execution time
- Keeping eyes open for problems when running coroutines
Chapter 1 dived into concurrency, looking at how we can achieve it with both processes and threads. We also explored how we could utilize non-blocking I/O and an event loop to achieve concurrency with only one thread. In this chapter, we’ll cover the basics of how to write programs using this single-threaded concurrency model with asyncio. Using the techniques in this chapter, you’ll be able to take long-running operations, such as web requests, database queries, and network ...
Get Python Concurrency with asyncio now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.