code: def command_queue_worker(self, command_queue):
          
          while True:
              try:
                  # set timeout to ensure self.stopping is checked periodically
                  command, data = command_queue.get(timeout=3)
                  try:
                      self.process_command(command, data)
                  except Exception as e:
                      _logger.exception(e)
                      self.worker_exceptions.append(e)
                      break
              except Empty:
                  pass
              if self.stopping and (_worker_fast_exit_on_terminate or command_queue.empty()):
                  break
docs: Process commands in command queues.