Socket connection timeout
A new Python socket by default doesn't have a timeout. Its timeout defaults to None. Not setting the connection timeout parameter can result in blocking socket mode. In blocking mode, operations block until complete or the system returns an error.
def create_socket_noncompliant(samplehost, sampleport, samplebuffersize):
    import socket
    # Noncompliant: socket timeout is not set.
    socket = socket.create_connection((samplehost, sampleport))
    try:
        print(socket.recv(samplebuffersize))
    finally:
        socket.close()
def create_socket_compliant(samplehost, sampleport, samplebuffersize):
    import socket
    # Compliant: socket timeout is set.
    socket = socket.create_connection((samplehost, sampleport), timeout=10)
    try:
        print(socket.recv(samplebuffersize))
    finally:
        socket.close()