def close(self, reason=None):
        """
        Stop consuming messages and perform an orderly shutdown.

        If ``reason`` is None, then this is considered a regular close.
        """
        with self._closing:
            if self._closed:
                return

            self._websocket.close()

            self._consumer.join()
            self._consumer = None

            self._websocket = None
            self._closed = True
            for cb in self._close_callbacks:
                cb(self, reason)
def close ( self , reason = None ) : with self . _closing : if self . _closed : return self . _websocket . close ( ) self . _consumer . join ( ) self . _consumer = None self . _websocket = None self . _closed = True for cb in self . _close_callbacks : cb ( self , reason )
Stop consuming messages and perform an orderly shutdown.

        If ``reason`` is None, then this is considered a regular close.