And inside: with client_socket: you don't also need: client_socket.close() The context manager already closes it.
And inside:
with client_socket:
you don't also need:
client_socket.close()
The context manager already closes it.