def __init__(self, query, sock_timeout=3, **kw):
        """
        Initialize the web socket.
        
        :param Query query: Query type from `smc_monitoring.monitors`
        :param int sock_timeout: length of time to wait on a select call
            before trying to receive data. For LogQueries, this should be
            short, i.e. 1 second. For other queries the default is 3 sec.
        :param int max_recv: for queries that are not 'live', set
            this to supply a max number of receive iterations.
        :param kw: supported keyword args:
            cert_reqs: ssl.CERT_NONE|ssl.CERT_REQUIRED|ssl.CERT_OPTIONAL
            check_hostname: True|False
            enable_multithread: True|False (Default: True)
        
        .. note:: The keyword args are not required unless you want to override
            default settings. If SSL is used for the SMC session, the settings
            for verifying the server with the root CA is based on whether the
            'verify' setting has been provided with a path to the root CA file.
        """
        if not session.session or not session.session.cookies:
            raise SessionNotFound('No SMC session found. You must first '
                'obtain an SMC session through session.login before making '
                'a web socket connection.')
        
        sslopt = {}
        if session.is_ssl:
            # SSL verification is based on the session settings since the
            # session must be made before calling this class. If verify=True, 
            # try to get the CA bundle from certifi if the package exists
            # Set check_hostname to False because python ssl doesn't appear
            # to validate the subjectAltName properly, however requests does
            # and would have already validated this when the session was set
            # up. This can still be overridden by setting check_hostname=True.
            sslopt.update(
                cert_reqs=ssl.CERT_NONE,
                check_hostname=False)
    
            certfile = session.session.verify
            if certfile:
                if isinstance(certfile, bool): # verify=True
                    certfile = _get_ca_bundle()
                    if certfile is None:
                        certfile = ''
                
                sslopt.update(
                    cert_reqs=kw.pop('cert_reqs', ssl.CERT_REQUIRED),
                    check_hostname=kw.pop('check_hostname', False))
                
                if sslopt.get('cert_reqs') != ssl.CERT_NONE:
                    os.environ['WEBSOCKET_CLIENT_CA_BUNDLE'] = certfile
        
        # Enable multithread locking
        if 'enable_multithread' not in kw:
            kw.update(enable_multithread=True)
        
        # Max number of receives, configurable for batching
        self.max_recv = kw.pop('max_recv', 0)
        
        super(SMCSocketProtocol, self).__init__(sslopt=sslopt, **kw)
        
        self.query = query
        self.fetch_id = None
        # Inner thread used to keep socket select alive
        self.thread = None
        self.event = threading.Event()
        self.sock_timeout = sock_timeout
def __init__ ( self , query , sock_timeout = 3 , ** kw ) : if not session . session or not session . session . cookies : raise SessionNotFound ( 'No SMC session found. You must first ' 'obtain an SMC session through session.login before making ' 'a web socket connection.' ) sslopt = { } if session . is_ssl : sslopt . update ( cert_reqs = ssl . CERT_NONE , check_hostname = False ) certfile = session . session . verify if certfile : if isinstance ( certfile , bool ) : certfile = _get_ca_bundle ( ) if certfile is None : certfile = '' sslopt . update ( cert_reqs = kw . pop ( 'cert_reqs' , ssl . CERT_REQUIRED ) , check_hostname = kw . pop ( 'check_hostname' , False ) ) if sslopt . get ( 'cert_reqs' ) != ssl . CERT_NONE : os . environ [ 'WEBSOCKET_CLIENT_CA_BUNDLE' ] = certfile if 'enable_multithread' not in kw : kw . update ( enable_multithread = True ) self . max_recv = kw . pop ( 'max_recv' , 0 ) super ( SMCSocketProtocol , self ) . __init__ ( sslopt = sslopt , ** kw ) self . query = query self . fetch_id = None self . thread = None self . event = threading . Event ( ) self . sock_timeout = sock_timeout
Initialize the web socket.
        
        :param Query query: Query type from `smc_monitoring.monitors`
        :param int sock_timeout: length of time to wait on a select call
            before trying to receive data. For LogQueries, this should be
            short, i.e. 1 second. For other queries the default is 3 sec.
        :param int max_recv: for queries that are not 'live', set
            this to supply a max number of receive iterations.
        :param kw: supported keyword args:
            cert_reqs: ssl.CERT_NONE|ssl.CERT_REQUIRED|ssl.CERT_OPTIONAL
            check_hostname: True|False
            enable_multithread: True|False (Default: True)
        
        .. note:: The keyword args are not required unless you want to override
            default settings. If SSL is used for the SMC session, the settings
            for verifying the server with the root CA is based on whether the
            'verify' setting has been provided with a path to the root CA file.