Book Image

Mastering Python Networking - Fourth Edition

By : Eric Chou
Book Image

Mastering Python Networking - Fourth Edition

By: Eric Chou

Overview of this book

Networks in your infrastructure set the foundation for how your application can be deployed, maintained, and serviced. Python is the ideal language for network engineers to explore tools that were previously available to systems engineers and application developers. In Mastering Python Networking, Fourth edition, you'll embark on a Python-based journey to transition from a traditional network engineer to a network developer ready for the next generation of networks. This new edition is completely revised and updated to work with the latest Python features and DevOps frameworks. In addition to new chapters on introducing Docker containers and Python 3 Async IO for network engineers, each chapter is updated with the latest libraries with working examples to ensure compatibility and understanding of the concepts. Starting with a basic overview of Python, the book teaches you how it can interact with both legacy and API-enabled network devices. You will learn to leverage high-level Python packages and frameworks to perform network automation tasks, monitoring, management, and enhanced network security, followed by AWS and Azure cloud networking. You will use Git for code management, GitLab for continuous integration, and Python-based testing tools to verify your network.
Table of Contents (19 chapters)
17
Other Books You May Enjoy
18
Index

Asynchronous Operations Overview

In the ‘Zen of Python,’ we know one of the guiding principles in Python is to preferably have ‘one best way to do something.’ When it comes to asynchronous operations, it is a bit complicated. We know it would help if we could do multiple tasks simultaneously but determining the correct solution might not be straightforward.

First, we will need to determine what is slowing down our program. Typically, the bottleneck can be either CPU-bound or IO-bound. In a CPU-bound situation, the program pushes the CPU to its limit. Operations such as solving mathematical questions or image processing are examples of CPU-bound programs. For example, when we pick an encryption algorithm for VPN, we know the more complex the algorithm, the more CPU it would consume. For CPU-bound tasks, the way to mitigate the bottleneck is to increase the CPU power or allow the task to use multiple CPUs simultaneously.

In an IO-bound operation, the program...