(self, wsURL)
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):
        '''Connect to the websocket in a thread.'''
        self.logger.debug("Starting thread")

        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,
                                         # We can login using email/pass or API key
                                         header=self.__get_auth())

        self.wst = threading.Thread(target=lambda: self.ws.run_forever())
        self.wst.daemon = True
        self.wst.start()
        self.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:
            self.logger.error("Couldn't connect to WS! Exiting.")
            self.exit()
            sys.exit(1)
def __connect ( self , wsURL ) : self . logger . debug ( "Starting thread" ) 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 , # We can login using email/pass or API key header = self . __get_auth ( ) ) self . wst = threading . Thread ( target = lambda : self . ws . run_forever ( ) ) self . wst . daemon = True self . wst . start ( ) self . 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 : self . logger . error ( "Couldn't connect to WS! Exiting." ) self . exit ( ) sys . exit ( 1 )