class_docstr: Pulls messages from a PubSub subscription and passes them through XCom.
  
  Always waits for at least one message to be returned from the subscription.
  
  .. seealso::
      For more information on how to use this operator, take a look at the guide:
      :ref:`howto/operator:PubSubPullSensor`
  
  .. seealso::
      If you don't want to wait for at least one message to come, use Operator instead:
      :class:`~airflow.providers.google.cloud.operators.pubsub.PubSubPullOperator`
  
  This sensor operator will pull up to ``max_messages`` messages from the
  specified PubSub subscription. When the subscription returns messages,
  the poke method's criteria will be fulfilled and the messages will be
  returned from the operator and passed through XCom for downstream tasks.
  
  If ``ack_messages`` is set to True, messages will be immediately
  acknowledged before being returned, otherwise, downstream tasks will be
  responsible for acknowledging them.
  
  If you want a non-blocking task that does not to wait for messages, please use
  :class:`~airflow.providers.google.cloud.operators.pubsub.PubSubPullOperator`
  instead.
  
  ``project_id`` and ``subscription`` are templated so you can use
  variables in them.
  
  :param project_id: the Google Cloud project ID for the subscription (templated)
  :param subscription: the Pub/Sub subscription name. Do not include the
      full subscription path.
  :param max_messages: The maximum number of messages to retrieve per
      PubSub pull request
  :param ack_messages: If True, each message will be acknowledged
      immediately rather than by any downstream tasks
  :param gcp_conn_id: The connection ID to use connecting to
      Google Cloud.
  :param messages_callback: (Optional) Callback to process received messages.
      Its return value will be saved to XCom.
      If you are pulling large messages, you probably want to provide a custom callback.
      If not provided, the default implementation will convert `ReceivedMessage` objects
      into JSON-serializable dicts using `google.protobuf.json_format.MessageToDict` function.
  :param impersonation_chain: Optional service account to impersonate using short-term
      credentials, or chained list of accounts required to get the access_token
      of the last account in the list, which will be impersonated in the request.
      If set as a string, the account must grant the originating account
      the Service Account Token Creator IAM role.
      If set as a sequence, the identities from the list must grant
      Service Account Token Creator IAM role to the directly preceding identity, with first
      account from the list granting this role to the originating account (templated).
  :param deferrable: Run sensor in deferrable mode
code: def poke(self, context: Context) -> bool:
      hook = PubSubHook(
          gcp_conn_id=self.gcp_conn_id,
          impersonation_chain=self.impersonation_chain,
      )
  
      pulled_messages = hook.pull(
          project_id=self.project_id,
          subscription=self.subscription,
          max_messages=self.max_messages,
          return_immediately=True,
      )
  
      handle_messages = (
          self.messages_callback or self._default_message_callback
      )
  
      self._return_value = handle_messages(pulled_messages, context)
  
      if pulled_messages and self.ack_messages:
          hook.acknowledge(
              project_id=self.project_id,
              subscription=self.subscription,
              messages=pulled_messages,
          )
  
      return bool(pulled_messages)
  
file_path: airflow/airflow/providers/google/cloud/sensors/pubsub.py
imports: from __future__ import annotations
  from datetime import timedelta
  from typing import TYPE_CHECKING, Any, Callable, Sequence
  from google.cloud.pubsub_v1.types import ReceivedMessage
  from airflow.configuration import conf
  from airflow.exceptions import AirflowException, AirflowSkipException
  from airflow.providers.google.cloud.hooks.pubsub import PubSubHook
  from airflow.providers.google.cloud.triggers.pubsub import PubsubPullTrigger
  from airflow.sensors.base import BaseSensorOperator
label_desc: Use image node_id 2 for calling the PubSubPullSensor obj's underlying member method code with example usage: obj.poke(context) and returns: bool