connectordb/_websocket.py
def connect(self):
        """Attempt to connect to the websocket - and returns either True or False depending on if
        the connection was successful or not"""

        # Wait for the lock to be available (ie, the websocket is not being used (yet))
        self.ws_openlock.acquire()
        self.ws_openlock.release()

        if self.status == "connected":
            return True  # Already connected
        if self.status == "disconnecting":
            # If currently disconnecting, wait a moment, and retry connect
            time.sleep(0.1)
            return self.connect()
        if self.status == "disconnected" or self.status == "reconnecting":
            self.ws = websocket.WebSocketApp(self.ws_url,
                                             header=self.headers,
                                             on_message=self.__on_message,
                                             on_ping=self.__on_ping,
                                             on_open=self.__on_open,
                                             on_close=self.__on_close,
                                             on_error=self.__on_error)
            self.ws_thread = threading.Thread(target=self.ws.run_forever)
            self.ws_thread.daemon = True

            self.status = "connecting"
            self.ws_openlock.acquire()
            self.ws_thread.start()

        self.ws_openlock.acquire()
        self.ws_openlock.release()

        return self.status == "connected"
def connect(self):
        """Attempt to connect to the websocket - and returns either True or False depending on if
        the connection was successful or not"""

        # Wait for the lock to be available (ie, the websocket is not being used (yet))
        self.ws_openlock.acquire()
        self.ws_openlock.release()

        if self.status == "connected":
            return True  # Already connected
        if self.status == "disconnecting":
            # If currently disconnecting, wait a moment, and retry connect
            time.sleep(0.1)
            return self.connect()
        if self.status == "disconnected" or self.status == "reconnecting":
            self.ws = websocket.WebSocketApp(self.ws_url,
                                             header=self.headers,
                                             on_message=self.__on_message,
                                             on_ping=self.__on_ping,
                                             on_open=self.__on_open,
                                             on_close=self.__on_close,
                                             on_error=self.__on_error)
            self.ws_thread = threading.Thread(target=self.ws.run_forever)
            self.ws_thread.daemon = True

            self.status = "connecting"
            self.ws_openlock.acquire()
            self.ws_thread.start()

        self.ws_openlock.acquire()
        self.ws_openlock.release()

        return self.status == "connected"
def connect ( self ) : # Wait for the lock to be available (ie, the websocket is not being used (yet)) self . ws_openlock . acquire ( ) self . ws_openlock . release ( ) if self . status == "connected" : return True # Already connected if self . status == "disconnecting" : # If currently disconnecting, wait a moment, and retry connect time . sleep ( 0.1 ) return self . connect ( ) if self . status == "disconnected" or self . status == "reconnecting" : self . ws = websocket . WebSocketApp ( self . ws_url , header = self . headers , on_message = self . __on_message , on_ping = self . __on_ping , on_open = self . __on_open , on_close = self . __on_close , on_error = self . __on_error ) self . ws_thread = threading . Thread ( target = self . ws . run_forever ) self . ws_thread . daemon = True self . status = "connecting" self . ws_openlock . acquire ( ) self . ws_thread . start ( ) self . ws_openlock . acquire ( ) self . ws_openlock . release ( ) return self . status == "connected"
Attempt to connect to the websocket - and returns either True or False depending on if
        the connection was successful or not
Attempt to connect to the websocket - and returns either True or False depending on if the connection was successful or not