<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _consume(self):
 """ Consume commands from the queue. The command is repeated according to the configured value. Wait after each command is sent. The bridge socket is a shared resource. It must only be used by one thread at a time. Note that this can and will delay commands if multiple groups are attempting to communicate at the same time on the same bridge. """

        while not self.is_closed:
            # Get command from queue.
            msg = self._command_queue.get()

            # Closed
            if msg is None:
                return

            # Use the lock so we are sure is_ready is not changed during execution
            # and the socket is not in use
            with self._lock:
                # Check if bridge is ready
                if self.is_ready:
                    (command, reps, wait) = msg

                    # Select group if a different group is currently selected.
                    if command.select and self._selected_number != command.group_number:
                        if self._send_raw(command.select_command.get_bytes(self)):
                            self._selected_number = command.group_number
                            time.sleep(SELECT_WAIT)
                        else:
                            # Stop sending on socket error
                            self.is_ready = False

                    # Repeat command as necessary.
                    for _ in range(reps):
                        if self.is_ready:
                            if self._send_raw(command.get_bytes(self)):
                                time.sleep(wait)
                            else:
                                # Stop sending on socket error
                                self.is_ready = False

            # Wait if bridge is not ready, we're only reading is_ready, no lock needed
            if not self.is_ready and not self.is_closed:
                # For older bridges, always try again, there's no keep-alive thread
                if self.version < 6:
                    # Give the reconnect some time
                    time.sleep(RECONNECT_TIME)
                    self.is_ready = True