btfxwss/queue_processor.py
def run(self):
        """Main routine.

        :return:
        """
        while not self._stopped.is_set():
            try:
                message = self.q.get(timeout=0.1)
            except Empty:
                continue

            dtype, data, ts = message
            if dtype in ('subscribed', 'unsubscribed', 'conf', 'auth', 'unauth'):
                try:
                    self._response_handlers[dtype](dtype, data, ts)
                except KeyError:
                    self.log.error("Dtype '%s' does not have a response "
                                   "handler! (%s)", dtype, message)
            elif dtype == 'data':
                try:
                    channel_id = data[0]
                    if channel_id != 0:
                        # Get channel type associated with this data to the
                        # associated data type (from 'data' to
                        # 'book', 'ticker' or similar
                        channel_type, *_ = self.channel_directory[channel_id]

                        # Run the associated data handler for this channel type.
                        self._data_handlers[channel_type](channel_type, data, ts)
                        # Update time stamps.
                        self.update_timestamps(channel_id, ts)
                    else:
                        # This is data from auth channel, call handler
                        self._handle_account(data=data, ts=ts)
                except KeyError:
                    self.log.error("Channel ID does not have a data handler! %s",
                                   message)
            else:
                self.log.error("Unknown dtype on queue! %s", message)
                continue
def run(self):
        """Main routine.

        :return:
        """
        while not self._stopped.is_set():
            try:
                message = self.q.get(timeout=0.1)
            except Empty:
                continue

            dtype, data, ts = message
            if dtype in ('subscribed', 'unsubscribed', 'conf', 'auth', 'unauth'):
                try:
                    self._response_handlers[dtype](dtype, data, ts)
                except KeyError:
                    self.log.error("Dtype '%s' does not have a response "
                                   "handler! (%s)", dtype, message)
            elif dtype == 'data':
                try:
                    channel_id = data[0]
                    if channel_id != 0:
                        # Get channel type associated with this data to the
                        # associated data type (from 'data' to
                        # 'book', 'ticker' or similar
                        channel_type, *_ = self.channel_directory[channel_id]

                        # Run the associated data handler for this channel type.
                        self._data_handlers[channel_type](channel_type, data, ts)
                        # Update time stamps.
                        self.update_timestamps(channel_id, ts)
                    else:
                        # This is data from auth channel, call handler
                        self._handle_account(data=data, ts=ts)
                except KeyError:
                    self.log.error("Channel ID does not have a data handler! %s",
                                   message)
            else:
                self.log.error("Unknown dtype on queue! %s", message)
                continue
Main routine.

        :return: