market_maker/ws/ws_thread.py
def __connect(self, wsURL):
        '''Connect to the websocket in a thread.'''
        logger.debug("Starting thread")

        ssl_defaults = ssl.get_default_verify_paths()
        sslopt_ca_certs = {'ca_certs': ssl_defaults.cafile}
        self.ws = websocket.WebSocketApp(wsURL,
                                         on_message=self.__on_message,
                                         on_close=self.__on_close,
                                         on_open=self.__on_open,
                                         on_error=self.__on_error,
                                         header=self.__get_auth()
                                         )

        self.wst = threading.Thread(target=lambda: self.ws.run_forever(sslopt=sslopt_ca_certs))
        self.wst.daemon = True
        self.wst.start()
        logger.info("Started thread")

        # Wait for connect before continuing
        conn_timeout = 5
        while (not self.ws.sock or not self.ws.sock.connected) and conn_timeout and not self._error:
            sleep(1)
            conn_timeout -= 1

        if not conn_timeout or self._error:
            logger.error("Couldn't connect to WS! Exiting.")
            self.exit()
            sys.exit(1)
Connect to the websocket in a thread.
Connect to the websocket in a thread.
Connect to the websocket in a thread .
def __connect(self, wsURL):
        logger.debug("Starting thread")
        ssl_defaults = ssl.get_default_verify_paths()
        sslopt_ca_certs = {'ca_certs': ssl_defaults.cafile}
        self.ws = websocket.WebSocketApp(wsURL,
                                         on_message=self.__on_message,
                                         on_close=self.__on_close,
                                         on_open=self.__on_open,
                                         on_error=self.__on_error,
                                         header=self.__get_auth()
                                         )
        self.wst = threading.Thread(target=lambda: self.ws.run_forever(sslopt=sslopt_ca_certs))
        self.wst.daemon = True
        self.wst.start()
        logger.info("Started thread")
        conn_timeout = 5
        while (not self.ws.sock or not self.ws.sock.connected) and conn_timeout and not self._error:
            sleep(1)
            conn_timeout -= 1
        if not conn_timeout or self._error:
            logger.error("Couldn't connect to WS! Exiting.")
            self.exit()
            sys.exit(1)
def __connect ( self , wsURL ) : logger . debug ( "Starting thread" ) ssl_defaults = ssl . get_default_verify_paths ( ) sslopt_ca_certs = { 'ca_certs' : ssl_defaults . cafile } self . ws = websocket . WebSocketApp ( wsURL , on_message = self . __on_message , on_close = self . __on_close , on_open = self . __on_open , on_error = self . __on_error , header = self . __get_auth ( ) ) self . wst = threading . Thread ( target = lambda : self . ws . run_forever ( sslopt = sslopt_ca_certs ) ) self . wst . daemon = True self . wst . start ( ) logger . info ( "Started thread" ) conn_timeout = 5 while ( not self . ws . sock or not self . ws . sock . connected ) and conn_timeout and not self . _error : sleep ( 1 ) conn_timeout -= 1 if not conn_timeout or self . _error : logger . error ( "Couldn't connect to WS! Exiting." ) self . exit ( ) sys . exit ( 1 )
Connect to the websocket in a thread.
Connect to the websocket in a thread .
'''Connect to the websocket in a thread.''' # Wait for connect before continuing
self
wsURL