(self, status = STATUS_NORMAL, reason = "")
Close Websocket object

        status: status code to send. see STATUS_XXX.

        reason: the reason to close. This must be string.
Close Websocket object
Close Websocket object
def close(self, status = STATUS_NORMAL, reason = ""):
        """
        Close Websocket object

        status: status code to send. see STATUS_XXX.

        reason: the reason to close. This must be string.
        """
        if self.connected:
            if status < 0 or status >= ABNF.LENGTH_16:
                raise ValueError("code is invalid range")

            try:
                self.send(struct.pack('!H', status) + reason, ABNF.OPCODE_CLOSE)
                timeout = self.sock.gettimeout()
                self.sock.settimeout(3)
                try:
                    frame = self.recv_frame()
                    if logger.isEnabledFor(logging.DEBUG):
                        logger.error("close status: " + repr(frame.data))
                except:
                    pass
                self.sock.settimeout(timeout)
                self.sock.shutdown(socket.SHUT_RDWR)
            except:
                pass
        self._closeInternal()
def close ( self , status = STATUS_NORMAL , reason = "" ) : if self . connected : if status < 0 or status >= ABNF . LENGTH_16 : raise ValueError ( "code is invalid range" ) try : self . send ( struct . pack ( '!H' , status ) + reason , ABNF . OPCODE_CLOSE ) timeout = self . sock . gettimeout ( ) self . sock . settimeout ( 3 ) try : frame = self . recv_frame ( ) if logger . isEnabledFor ( logging . DEBUG ) : logger . error ( "close status: " + repr ( frame . data ) ) except : pass self . sock . settimeout ( timeout ) self . sock . shutdown ( socket . SHUT_RDWR ) except : pass self . _closeInternal ( )