logging.warning("connection to %s has timed out" % str(client_address)) finally: logging.info("closing connection to %s" % str(client_address)) connection.close() if __name__ == "__main__": logging.basicConfig(filename='aor_lookup.log', level=logging.DEBUG, format='%(asctime)s %(levelname)s %(message)s') logging.info("starting up the server") registers = Registers() registers.from_file(REGISTRATION_FILEPATH) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_address = ('', PORT) sock.bind(server_address) sock.listen(1) logging.info("listening on port %d" % PORT) while True: connection, client_address = sock.accept() logging.info("accepted connection from %s" % str(client_address)) connection.settimeout(CONNECTION_TIMEOUT) logging.info("starting new thread to process request from %s" % str(client_address))