Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

sample: add publish flow control sample and other nits#429

Merged
pradn merged 4 commits intomasterfrom
publish-flow
Jun 17, 2021
Merged

sample: add publish flow control sample and other nits#429
pradn merged 4 commits intomasterfrom
publish-flow

Conversation

@anguillanneuf
Copy link
Contributor

For internal b/191088429

@anguillanneuf anguillanneuf requested a review from a team as a code owner June 15, 2021 18:27
@anguillanneuf anguillanneuf requested review from engelke and removed request for a team June 15, 2021 18:27
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Jun 15, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jun 15, 2021
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jun 15, 2021
@snippet-bot
Copy link

snippet-bot bot commented Jun 15, 2021

Here is the summary of changes.

You are about to add 1 region tag.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

Copy link
Contributor

@plamut plamut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, except for the exception type that we want to catch.

except: # noqa
print("Please handle {} for {}.".format(f.exception(), data))
# Wait 100 ms for the publish call to succeed.
print(publish_future.result(timeout=0.1))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting only 100ms is likely to result in deadline exceeded failures. It's best not to set a deadline or if necessary, set a deadline closer to 60s.

message_id = publish_future.result()
print(message_id)

# Publish 1000 messages in quick succession to trigger flow control.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't say "to trigger flow control." It's possible that flow control will be triggered, but it's also entirely possible it won't be if messages get out quickly enough. Either way, the fact that flow control was triggered isn't something that will be easily visible to the user. Maybe say "Rapidly publishing 1000 messages in a loop may be constrained by flow control."

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: pubsub Issues related to the googleapis/python-pubsub API. cla: yes This human has signed the Contributor License Agreement. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants