From 8dca3e8d20b8606235175a6519d143892745777a Mon Sep 17 00:00:00 2001 From: oli Date: Tue, 13 Aug 2019 06:02:18 +1000 Subject: [PATCH] Print actual number of messages pulled [(#2078)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/2078) * Print actual number of messages pulled --- samples/snippets/subscriber.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/samples/snippets/subscriber.py b/samples/snippets/subscriber.py index 64e939515..181e8235b 100644 --- a/samples/snippets/subscriber.py +++ b/samples/snippets/subscriber.py @@ -284,7 +284,8 @@ def synchronous_pull(project_id, subscription_name): # Acknowledges the received messages so they will not be sent again. subscriber.acknowledge(subscription_path, ack_ids) - print("Received and acknowledged {} messages. Done.".format(NUM_MESSAGES)) + print('Received and acknowledged {} messages. Done.'.format( + len(response.received_messages))) # [END pubsub_subscriber_sync_pull] @@ -357,7 +358,8 @@ def worker(msg): if processes: time.sleep(SLEEP_TIME) - print("Received and acknowledged {} messages. Done.".format(NUM_MESSAGES)) + print('Received and acknowledged {} messages. Done.'.format( + len(response.received_messages))) # [END pubsub_subscriber_sync_pull_with_lease]