code: def _thread_main(self):
          
          _LOGGER.debug("Background thread started.")
  
          quit_ = False
          while True:
              batch = self._cloud_logger.batch()
              items = _get_many(
                  self._queue,
                  max_items=self._max_batch_size,
                  max_latency=self._max_latency,
              )
  
              for item in items:
                  if item is _WORKER_TERMINATOR:
                      quit_ = True
                      # Continue processing items, don't break, try to process
                      # all items we got back before quitting.
                  else:
                      batch.log_struct(**item)
  
              self._safely_commit_batch(batch)
  
              for _ in range(len(items)):
                  self._queue.task_done()
  
              if quit_:
                  break
  
          _LOGGER.debug("Background thread exited gracefully.")
docs: The entry point for the worker thread.
  
          Pulls pending log entries off the queue and writes them in batches to
          the Cloud Logger.