Book Image

Daniel Arbuckle's Mastering Python

By : Daniel Arbuckle
Book Image

Daniel Arbuckle's Mastering Python

By: Daniel Arbuckle

Overview of this book

Daniel Arbuckle's Mastering Python covers the basics of operating in a Python development environment, before moving on to more advanced topics. Daniel presents you with real-world solutions to Python 3.6 and advanced-level concepts, such as reactive programming, microservices, ctypes, and Cython tools. You don't need to be familiar with the Python language to use this book, as Daniel starts with a Python primer. Throughout, Daniel highlights the major aspects of managing your Python development environment, shows you how to handle parallel computation, and helps you to master asynchronous I/O with Python 3.6 to improve performance. Finally, Daniel will teach you the secrets of metaprogramming and unit testing in Python, helping you acquire the perfect skillset to be a Python expert. Daniel will get you up to speed on everything from basic programming practices to high-end tools and techniques, things that will help set you apart as a successful Python programmer.
Table of Contents (13 chapters)

Coroutines and Asynchronous I/O

In the previous chapter, we looked at how to use multiple processes to increase the rate of data processing in our programs. This is great for CPU-bound programs because it allows them to use more than one CPU.

In this chapter, we'll look at the inverse of this case; we'll use a single CPU to handle multiple data processing tasks at once within a single process, which is great for I/O-bound programs. We'll see some of the nuts and bolts of working with asyncio. We'll also discuss asyncio's future class and how it's used. Then we'll move on to synchronization and communication between asynchronous coroutine tasks. Lastly, we'll see how to use asyncio and coroutines to write a client-server program to communicate over a network.

We will cover the following topics:

  • The difference between asynchronous processing...