Book Image

Learning Python Network Programming

By : Dr. M. O. Faruque Sarker, Samuel B Washington, Sam Washington
Book Image

Learning Python Network Programming

By: Dr. M. O. Faruque Sarker, Samuel B Washington, Sam Washington

Overview of this book

Table of Contents (17 chapters)
Learning Python Network Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Taking our servers forward


There are a number of things that we can do to improve our servers. For multithreaded systems, it's common to have a mechanism for capping the number of threads in use at any one time. This can be done by keeping a count of the active threads and immediately closing any new incoming connections from clients while it's above a threshold.

For all our servers, we would also want to add a logging mechanism. I strongly recommend the standard library logging module for this, the documentation for this is complete and full of good examples. The basic tutorial is a good place to start if you've not used it before, and it can be found at https://docs.python.org/3/howto/logging.html#logging-basic-tutorial.

We also want to handle errors more comprehensively. Since the intention is that our server should be long running with minimal intervention, we want to make sure that nothing less than a critical exception causes the process to exit. We also want to make sure that errors...