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)

Communicating across the network

So, we've covered how asyncio works and a bunch of tools that could be used to manage the execution of multiple streams of code. That's all great, but what about doing some actual I/O with it?

The primary motivation for people to use asynchronous I/O is because it helps when writing network clients and servers, although that's certainly not the only possible use. So, asyncio not only makes network communications efficient, it also makes them easy.

Creating a simple client in asyncio

Here, we have the code for a simple client-server pair of programs (refer to the following code example):

They not only read and write the same few bytes over and over, but they also serve to demonstrate...