code: def _main_thread_terminated(self):
          
          if not self.is_alive:
              return
  
          if not self._queue.empty():
              print(
                  "Program shutting down, attempting to send %d queued log "
                  "entries to Stackdriver Logging..." % (self._queue.qsize(),),
                  file=sys.stderr,
              )
  
          if self.stop(self._grace_period):
              print("Sent all pending logs.", file=sys.stderr)
          else:
              print(
                  "Failed to send %d pending logs." % (self._queue.qsize(),),
                  file=sys.stderr,
              )
docs: Callback that attempts to send pending logs before termination.