Skip to content

Commit

Permalink
samples: publish with error handler and flow control (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
anguillanneuf authored Jun 23, 2021
1 parent bae8dc6 commit 2446818
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions samples/snippets/publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ def publish_messages_with_error_handler(project_id, topic_id):
def get_callback(publish_future, data):
def callback(publish_future):
try:
# Wait 100 ms for the publish call to succeed.
print(publish_future.result(timeout=0.1))
# Wait 60 seconds for the publish call to succeed.
print(publish_future.result(timeout=60))
except futures.TimeoutError:
print(f"Publishing {data} timed out.")

Expand Down Expand Up @@ -246,7 +246,8 @@ def callback(publish_future):
message_id = publish_future.result()
print(message_id)

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

0 comments on commit 2446818

Please sign in to comment.