Skip to content

Commit 6e9aa1f

Browse files
samples: publish with error handler and flow control (#433)
1 parent ef5dce1 commit 6e9aa1f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

packages/google-cloud-pubsub/samples/snippets/publisher.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ def publish_messages_with_error_handler(project_id, topic_id):
150150
def get_callback(publish_future, data):
151151
def callback(publish_future):
152152
try:
153-
# Wait 100 ms for the publish call to succeed.
154-
print(publish_future.result(timeout=0.1))
153+
# Wait 60 seconds for the publish call to succeed.
154+
print(publish_future.result(timeout=60))
155155
except futures.TimeoutError:
156156
print(f"Publishing {data} timed out.")
157157

@@ -246,7 +246,8 @@ def callback(publish_future):
246246
message_id = publish_future.result()
247247
print(message_id)
248248

249-
# Publish 1000 messages in quick succession to trigger flow control.
249+
# Publish 1000 messages in quick succession may be constrained by
250+
# publisher flow control.
250251
for n in range(1, 1000):
251252
data = f"Message number {n}"
252253
# Data must be a bytestring

0 commit comments

Comments
 (0)