class_docstr: Watches for Kubernetes jobs.
class_docstr_tok: ["Watches","for","Kubernetes","jobs","."]
code: def _pod_events(
      self, kube_client: client.CoreV1Api, query_kwargs: dict
  ):
      watcher = watch.Watch()
      try:
          if self.namespace == ALL_NAMESPACES:
              return watcher.stream(
                  kube_client.list_pod_for_all_namespaces,
                  **query_kwargs,
              )
          else:
              return watcher.stream(
                  kube_client.list_namespaced_pod,
                  self.namespace,
                  **query_kwargs,
              )
      except ApiException as e:
          if e.status == 410:  # Resource version is too old
              if self.namespace == ALL_NAMESPACES:
                  pods = kube_client.list_pod_for_all_namespaces(
                      watch=False
                  )
              else:
                  pods = kube_client.list_namespaced_pod(
                      namespace=self.namespace, watch=False
                  )
              resource_version = pods.metadata.resource_version
              query_kwargs["resource_version"] = resource_version
              return self._pod_events(
                  kube_client=kube_client, query_kwargs=query_kwargs
              )
          else:
              raise
  
imports: from __future__ import annotations
  import contextlib
  import json
  import multiprocessing
  import time
  from queue import Empty, Queue
  from typing import TYPE_CHECKING, Any, Generic, TypeVar
  from kubernetes import client, watch
  from kubernetes.client.rest import ApiException
  from urllib3.exceptions import ReadTimeoutError
  from airflow.exceptions import AirflowException
  from airflow.providers.cncf.kubernetes.kube_client import get_kube_client
  from airflow.providers.cncf.kubernetes.kubernetes_helper_functions import annotations_for_logging_task_metadata, annotations_to_key, create_pod_id
  from airflow.providers.cncf.kubernetes.pod_generator import PodGenerator
  from airflow.utils.log.logging_mixin import LoggingMixin
  from airflow.utils.state import TaskInstanceState
label_desc: Use image node_id 3 for calling the KubernetesJobWatcher obj's underlying member method code with example usage: obj._pod_events(kube_client, query_kwargs) and returns: watcher, watcher, self