Skip to content

Commit 425e084

Browse files
committed
Update tracker in callback
1 parent cd4ec3f commit 425e084

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pubsub/cloud-client/quickstart.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ def create_subscription_safely(subscriber, subscription_path):
6666
num_messages = 10
6767

6868
def resolve_future_callback(future):
69-
# Resolve the future asynchronously and update key in `tracker`.
69+
# Resolve the future and update `tracker` asynchronously.
70+
tracker.update({future: {'pubtime': time.time(), 'subtime': None}})
7071
message_id = future.result()
7172
tracker[message_id] = tracker.pop(future)
7273

7374
def publish_messages(publish_func, callback):
7475
for i in range(num_messages):
7576
future = publish_func(topic_path, data=data, index=str(i))
76-
tracker.update({future: {'pubtime': time.time(), 'subtime': None}})
7777
callback(future)
7878

7979
# Publish messages.

0 commit comments

Comments
 (0)