Skip to content

Commit

Permalink
Testing: sync modack timed
Browse files Browse the repository at this point in the history
  • Loading branch information
mukund-ananthu committed Apr 22, 2024
1 parent ff229a5 commit 1b8918d
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -41,6 +41,7 @@
import google.cloud.pubsub_v1.subscriber.message
from google.cloud.pubsub_v1.subscriber import futures
from google.cloud.pubsub_v1.subscriber.scheduler import ThreadScheduler
from datetime import datetime
from google.pubsub_v1 import types as gapic_types
from grpc_status import rpc_status # type: ignore
from google.rpc.error_details_pb2 import ErrorInfo # type: ignore
Expand Down Expand Up @@ -1098,10 +1099,15 @@ def _on_response(self, response: gapic_types.StreamingPullResponse) -> None:
# Immediately (i.e. without waiting for the auto lease management)
# modack the messages we received, as this tells the server that we've
# received them.
before_acks = datetime.now()
ack_id_gen = (message.ack_id for message in received_messages)
expired_ack_ids = self._send_lease_modacks(
ack_id_gen, self.ack_deadline, warn_on_invalid=False
)
after_acks = datetime.now()
sync_modack_time_diff = after_acks - before_acks
print(f"time for sync modacking = {sync_modack_time_diff.total_seconds()*1000}")


with self._pause_resume_lock:
assert self._scheduler is not None
Expand Down

0 comments on commit 1b8918d

Please sign in to comment.