Learn how to speed up slow Python code with concurrent programming and the cutting-edge asyncio library.
Use coroutines and tasks alongside async/await syntax to run code concurrently Build web APIs and make concurrency web requests with aiohttp Run thousands of SQL queries concurrently Create a map-reduce job that can process gigabytes of data concurrently Use threading with asyncio to mix blocking code with asyncio code
Python is flexible, versatile, and easy to learn. It can also be very slow compared to lower-level languages. Python Concurrency with asyncio teaches you how to boost Python's performance by applying a variety of concurrency techniques. You'll learn how the complex-but-powerful asyncio library can achieve concurrency with just a single thread and use asyncio's APIs to run multiple web requests and database queries simultaneously. The book covers using asyncio with the entire Python concurrency landscape, including multiprocessing and multithreading.
Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.
About the technology It’s easy to overload standard Python and watch your programs slow to a crawl. Th e asyncio library was built to solve these problems by making it easy to divide and schedule tasks. It seamlessly handles multiple operations concurrently, leading to apps that are lightning fast and scalable.
About the book Python Concurrency with asyncio introduces asynchronous, parallel, and concurrent programming through hands-on Python examples. Hard-to-grok concurrency topics are broken down into simple flowcharts that make it easy to see how your tasks are running. You’ll learn how to overcome the limitations of Python using asyncio to speed up slow web servers and microservices. You’ll even combine asyncio with traditional multiprocessing techniques for huge improvements to performance.
What's inside
Build web APIs and make concurrency web requests with aiohttp Run thousands of SQL queries concurrently Create a map-reduce job that can process gigabytes of data concurrently Use threading with asyncio to mix blocking code with asyncio code
About the reader For intermediate Python programmers. No previous experience of concurrency required.
About the author Matthew Fowler has over 15 years of software engineering experience in roles from architect to engineering director.
Table of Contents 1 Getting to know asyncio 2 asyncio basics 3 A first asyncio application 4 Concurrent web requests 5 Non-blocking database drivers 6 Handling CPU-bound work 7 Handling blocking work with threads 8 Streams 9 Web applications 10 Microservices 11 Synchronization 12 Asynchronous queues 13 Managing subprocesses 14 Advanced asyncio
Amazing book. I read almost all books about async/await in Python, and this one is the best. I cover everything, including how to build your event loop and how to deal with functions that are not async. Not only did I read and learn about asyncio in Python, I also used it as a reference when I needed to deal with any type of asyncio problem. The book also uses type notations, which is very helpful. Thank you for doing that. I strongly recommend this book to anyone who wants to master asyncio in Python.
The examples in the book disclose that Python is not the author's most beloved programming language. Despite that, the book is good. If you are a Python developer, you will advance significantly by spending time on it.
Writing asynchronous code in Python is a valuable and in-demand skill. The book does its job of helping its readers master that skill. The author clearly explains the topics of the chapters.
The examples work as expected. You can experiment with them and gain hands-on experience with asyncio, aiohttp, multithreading, multiprocessing, etc.
This book fills in a much needed-gap left behind by the official python docs for the asyncio module. I think it does an excellent job of breaking down the core concepts behind asyncio (e.g., coroutines, futures, tasks, and the event loop) with concise code examples, and provides a decent amount of guidance on how to structure an asynchronous python app.
I really only have a couple of small criticisms of this book. One is that some of the sections which go into third-party libraries (e.g., Django) go a little too deep into the technical details of those libraries, and it's easy to lose track of the details that pertain to just asyncio. Luckily the book is structured well enough that you can skip over those chapters if you're not actually using those third-party libraries. Another is that I found the last chapter regarding building your own event loop a little tricky to follow. I think a slower, more in-depth walkthrough of this topic would help the reader out a lot. However, this is an advanced topic that very few asyncio users would need to dive into, so it's not a huge loss.
Overall, I would very much recommend this book to anyone who wants to really understand how asyncio works and finds the official docs lacking.
I read about half of the book to understand the basics of Python's asyncio and leave the more advanced chapters for later. The book's coverage is pretty comprehensive. The author builds the async pattern from ground up with concepts around non-blocking sockets and the event loops. He also shows how to use asyncio with traditional preemptive concurrency models such as threads & processes.
Based on what I've read, I'd give this a solid 4.5 stars. I docked .5 stars from it because the writing is a bit dry at times, but it's not too much of a problem if you're interested in the topic.
It's quite good but it has the same problem as many other technical books: they don't decide if they are directed to novices or experts. For example, the author feels the need to explain what a queue data structure is. But anyone who is advanced enough in software engineering that wants to learn about asynchronous programming will already know the basic data structures. In addition, the examples could be explained better.
Отличное пособие. Раньше асинхронность воспринималась чем-то сложным и непонятным. Автору же удалось доступным языком на простых примерах раскрыть ее возможности и способы применения.