Skip to content

Commit d1a0809

Browse files
olivercoadgguuss
authored andcommitted
Print actual number of messages pulled [(#2078)](GoogleCloudPlatform/python-docs-samples#2078)
* Print actual number of messages pulled
1 parent f395682 commit d1a0809

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

samples/snippets/subscriber.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ def synchronous_pull(project_id, subscription_name):
284284
# Acknowledges the received messages so they will not be sent again.
285285
subscriber.acknowledge(subscription_path, ack_ids)
286286

287-
print("Received and acknowledged {} messages. Done.".format(NUM_MESSAGES))
287+
print('Received and acknowledged {} messages. Done.'.format(
288+
len(response.received_messages)))
288289
# [END pubsub_subscriber_sync_pull]
289290

290291

@@ -357,7 +358,8 @@ def worker(msg):
357358
if processes:
358359
time.sleep(SLEEP_TIME)
359360

360-
print("Received and acknowledged {} messages. Done.".format(NUM_MESSAGES))
361+
print('Received and acknowledged {} messages. Done.'.format(
362+
len(response.received_messages)))
361363
# [END pubsub_subscriber_sync_pull_with_lease]
362364

363365

0 commit comments

Comments
 (0)