import os

_SOCKET_CLOSE_STRATEGY = os.getenv("ZMQ_SOCKET_CLOSE_STRATEGY", "DISCONNECT")


def close_socket(socket, socket_address, linger=1000):
    if _SOCKET_CLOSE_STRATEGY == "CLOSE":
        socket.close(linger=linger)
    else:
        try:
            socket.disconnect(socket_address)
        except:
            pass
        socket.close(linger=0)



