the socketserver module threadingmixin and tcpserver and creating an instane of this new class instead of the tcpserver directly for exampleclass threadedechoserversocketserver threadingmixinsocketserver tcpserver)pass def main()print('starting'address ('localhost' server threadedechoserver(addressmytcphandlerprint('activating server'server serve_forever(in fact you do not even need to create your own class (such as the threadedechoserveras the socketserver threadingtcpserver has been provided as default mixing of the tcpserver and the threadingmixin classes we could therefore just writedef main()print('starting'address ('localhost' server socketserver threadedechoserver(addressmytcphandlerprint('activating server'server serve_forever( http server in addition to the tcpserver you also have available http server httpserverthis can be used in similar manner to the tcpserverbut is used to create servers that respond to the http protocol used by web browsers in other words it can be used to create very simple web server (although it should be noted that it is really only suitable for creating test web servers as it only implements very basic security checksit is probably worth short aside to illustrate how web server and web browser interact the following diagram illustrates the basic interactions