Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samples: publish with error handler and flow control #433

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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