class_docstr: Shipper reads structured logs from logq and ships them to the determined-master.
  
  It will send a message on doneq when it finishes.
code: def __init__(
      self,
      master_url: str,
      token: str,
      cert_name: str,
      cert_file: str,
      logq: queue.Queue,
      doneq: queue.Queue,
      daemon: bool,
  ) -> None:
      super().__init__(daemon=daemon)
      self.logq = logq
      self.doneq = doneq
  
      # TODO(rb): Switch to DET_USER_TOKEN when the user token passed into a container isn't
      # limited to expire in 7 days, and then set `Authorization: Bearer $token` here instead.
      self.headers = {
          "Grpc-Metadata-x-allocation-token": f"Bearer {token}"
      }
  
      self.master_url = master_url
      self.cert_name = cert_name
      self.noverify = cert_file.lower() == "noverify"
      self.cert_content = None
      if cert_file and not self.noverify:
          try:
              with open(cert_file, "r") as f:
                  self.cert_content = f.read()
          except Exception:
              logging.error(
                  "failed to read DET_MASTER_CERT_FILE ({cert_file})",
                  with_exc=True,
              )
  
      self.base_url = master_url.rstrip("/")
      self.logs_url = f"{self.base_url}/api/v1/task/logs"
  
      self.context = None
      if master_url.startswith("https://"):
          # Create an SSLContext that trusts our DET_MASTER_CERT_FILE, and checks the hostname
          # against the DET_MASTER_CERT_NAME (which may differ from the hostname in the url).
          self.context = ssl.create_default_context()
          if self.noverify:
              # Don't check the master's certificate.
              # Presently the master never sets this value for DET_MASTER_CERT_FILE, but we keep
              # this check to be consistent with the CLI behavior.
              self.context.check_hostname = False
              self.context.verify_mode = ssl.CERT_NONE
          else:
              if cert_file:
                  # Explicitly trust the cert in cert_file.
                  self.context.load_verify_locations(
                      cadata=self.cert_content
                  )
              if cert_name:
                  # Override hostname verification
                  self.context = override_verify_name(
                      self.context, cert_name
                  )
  
imports: import datetime
  import io
  import json
  import logging
  import os
  import queue
  import re
  import signal
  import socket
  import ssl
  import subprocess
  import sys
  import threading
  import time
  import traceback
  import urllib.error
  import urllib.request
  from typing import Any, Dict, Iterator, List, NamedTuple, Optional, cast
label_desc: Use image node_id 1 to create a new Shipper object from inherited base classes: threading with example: obj = Shipper(master_url, token, cert_name, cert_file, logq, doneq, daemon)