(self, code=1000, reason='')
Call this method to initiate the websocket connection
        closing by sending a close frame to the connected peer.
        The ``code`` is the status code representing the
        termination's reason.

        Once this method is called, the ``server_terminated``
        attribute is set. Calling this method several times is
        safe as the closing frame will be sent only the first
        time.

        .. seealso:: Defined Status Codes http://tools.ietf.org/html/rfc6455#section-7.4.1
Call this method to initiate the websocket connection
        closing by sending a close frame to the connected peer.
        The ``code`` is the status code representing the
        termination's reason.
Call this method to initiate the websocket connection closing by sending a close frame to the connected peer . The code is the status code representing the termination s reason .
def close(self, code=1000, reason=''):
        """
        Call this method to initiate the websocket connection
        closing by sending a close frame to the connected peer.
        The ``code`` is the status code representing the
        termination's reason.

        Once this method is called, the ``server_terminated``
        attribute is set. Calling this method several times is
        safe as the closing frame will be sent only the first
        time.

        .. seealso:: Defined Status Codes http://tools.ietf.org/html/rfc6455#section-7.4.1
        """
        if not self.server_terminated:
            self.server_terminated = True
            self.sock.sendall(self.stream.close(code=code, reason=reason).single(mask=self.stream.always_mask))
def close ( self , code = 1000 , reason = '' ) : if not self . server_terminated : self . server_terminated = True self . sock . sendall ( self . stream . close ( code = code , reason = reason ) . single ( mask = self . stream . always_mask ) )