GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: support customizable retry and timeout settings on the publisher client by plamut · Pull Request #299 · googleapis/python-pubsub

This repository was archived by the owner on Oct 13, 2026. It is now read-only.

Conversation

@plamut

@plamut plamut commented Feb 26, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Closes #222.
Supersedes #239.

This PR adds support for API core timeout classes to the publisher class, replacing the previous float timeouts.

PR checklist:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
cguardia and others added 10 commits November 16, 2020 01:02
@cguardia
feat: allow retry and timeout settings on publisher client
729a5e7
@cguardia
build: update generated code and update doc
a9b5190
@cguardia
Merge branch 'master' into retry-timeout-settings
1b8767b
@cguardia
Merge branch 'master' into retry-timeout-settings
b06d122
@plamut
Merge branch 'master' into iss-222
54a1fd6
@plamut
Propagate publish timeout to the RPC call
12f2140
@plamut
test publisher client
240f992
@plamut
Fix timeout parameter type in docstrings
272ccdc
@plamut
Apply timeout changes to async publisher client
a0a1fcb
@plamut
Merge branch 'master' into iss-222
2d0046c
@plamut
plamut requested a review from a team February 26, 2021 22:25
@product-auto-label product-auto-label Bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Feb 26, 2021
@google-cla

google-cla Bot commented Feb 26, 2021

Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@google-cla google-cla Bot added the cla: no This human has *not* signed the Contributor License Agreement. label Feb 26, 2021
@plamut plamut mentioned this pull request Feb 26, 2021
wip: Allow retry and timeout settings on the publisher client #239
Closed
@plamut plamut changed the title Iss 222 feat: support customizable retry and timeout settings on the publisher client Feb 26, 2021
@cguardia

cguardia commented Feb 27, 2021

Copy link
Copy Markdown
Contributor

@googlebot I consent.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@google-cla google-cla Bot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Feb 27, 2021
@plamut
Merge branch 'master' into iss-222
3ad5779
@plamut
plamut requested a review from pradn April 28, 2021 10:20
@plamut plamut added kokoro:force-run Add this label to force Kokoro to re-run the tests. kokoro:run Add this label to force Kokoro to re-run the tests. labels Apr 30, 2021
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Apr 30, 2021
@jimfulton
jimfulton self-requested a review May 14, 2021 12:32
jimfulton
jimfulton reviewed May 16, 2021
View reviewed changes

@jimfulton jimfulton left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think the type UNION should admit floats and ints.

I also think the union should be defined once and reused.

There's an obscene amount of repetition in this package. It was already there, but may be can not add to it. :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread UPGRADING.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/types.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/publisher/client.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

plamut added 3 commits May 28, 2021 19:39
@plamut
Introduce TimeoutType type alias
ce8daea
@plamut
Update PublisherOptions docs
2adaba1
@plamut
Use type alias for timeout in upgrading guide
072d636
jimfulton
jimfulton reviewed May 28, 2021
View reviewed changes
Comment thread google/cloud/pubsub_v1/types.py Outdated


TimeoutType = Union[
None,

@jimfulton jimfulton May 28, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Did we mean to add None? Was this my fault?

This feels like an unintentional change. We didn't accept None before.

If we want to accept None, then I think we should update

https://github.com/googleapis/python-api-core/blob/7337c6b123735fb9ae5d0e54b4399275719c020c/google/api_core/gapic_v1/method.py#L66-L67

to treat None like DEFAULT.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@plamut plamut May 28, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actually we did, even though the argument description says otherwise. But the generated code actually used None as a default value for a supposedly float-only argument. :)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jimfulton
jimfulton reviewed May 28, 2021
View reviewed changes
Comment thread google/pubsub_v1/services/publisher/async_client.py Outdated
)

if timeout is None or isinstance(timeout, (int, float)):
timeout = timeouts.ConstantTimeout(timeout)

@jimfulton jimfulton May 28, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

We shouldn't need this except for the None case, which is new. I don't think we should accept None. Apologies if None came from me.

int and float are handled here:

https://github.com/googleapis/python-api-core/blob/7337c6b123735fb9ae5d0e54b4399275719c020c/google/api_core/gapic_v1/method.py#L66-L67

The same comment applies to other places where you added this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jimfulton jimfulton May 28, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

And, of course, not DRY.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jimfulton
jimfulton reviewed May 28, 2021
View reviewed changes
Comment thread google/cloud/pubsub_v1/publisher/_sequencer/base.py Outdated
@abc.abstractmethod
def publish(self, message, retry=None, timeout=None): # pragma: NO COVER
def publish(
self, message, retry=None, timeout: gapic_types.TimeoutType = None

@jimfulton jimfulton May 28, 2021

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Can we use DEFAULT rather than None? The implementation defaults to DEFAULT.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@plamut plamut May 28, 2021

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

That makes sense, the ABC should be consistent.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jimfulton
jimfulton reviewed May 28, 2021
View reviewed changes

@jimfulton jimfulton left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thanks for these changes.

My only complaint is that we added None as a valid timeout, which causes some pain.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut

plamut commented May 28, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@jimfulton I added None, because I noticed that ConstantTimeout actually supports it.

(not saying that explicitly disabling any timeouts is a good idea, but we already support that automaticlally if we allow instances of ConstantTimeout)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut

plamut commented May 28, 2021

Copy link
Copy Markdown
Contributor Author

Flaky samples tests, 500 internal.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 28, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 28, 2021
@jimfulton

jimfulton commented May 28, 2021

Copy link
Copy Markdown
Contributor

@jimfulton I added none, because I noticed that ConstantTimeout actually supports it.

(not saying that explicitly disabling any timeouts is a good idea, but we already support that automaticlally if we allow instances of ConstantTimeout)

That's fair, but at least you could argue that we should make people work to disable timeouts.

BTW, I tried to figure out what the effect of passing None to ConstantTimout would be and got lost in the web of indirection. :) To convince myself that I knew what was going on I'd have to spend some quality time with pdb, and I don't have time for that today.

In any case, if we want to accept None, I think we should handle that in one place (https://github.com/googleapis/python-api-core/blob/7337c6b123735fb9ae5d0e54b4399275719c020c/google/api_core/gapic_v1/method.py#L66-L67) so we don't repeat the logic in many places.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut
Use DEFAULT as a defualt timeout in base sequencer
762b129
@plamut

plamut commented May 28, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

I actually don't see a good reason why somebody wanted to potentially block indefinitely, thus I'm fine with removing support for a plain None (one can always pass in ConstantTimeout(None), if they really want to). We can then also get rid of the "convert constant to object" code in the generated code, because number constants are already handled in api-core.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut
Do not accept plain None as a valid timeout
b7939d1
Using no timeout is not a good idea, but if one really wants to,
they can pass it in as ConstantTimeout(None).

As a side effect, the logic of converting a constant into a
COnstantTimeout instance can be removed, as this is already handled
in api-core for int and float values.
@plamut

plamut commented May 28, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

BTW, I tried to figure out what the effect of passing None to ConstantTimout would be and got lost in the web of indirection. :)

If I read it correctly, a ConstantTimeout(None) is used as an RPC method decorator. What ConstantTimeout does is just setting the timeout argument to the wrapped method to the given value (None in this case).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut
plamut requested a review from jimfulton June 8, 2021 12:55
jimfulton
jimfulton approved these changes Jun 15, 2021
View reviewed changes
@plamut plamut added automerge Merge the pull request once unit tests and other checks pass. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Jun 15, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
@plamut

plamut commented Jun 15, 2021

Copy link
Copy Markdown
Contributor Author

Note to self - this PR modifies synth.py, thus after merging, we also need to update #411

cc: @parthea

parthea reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
@plamut plamut mentioned this pull request Jun 15, 2021
chore: migrate to owl bot #411
Merged
@plamut plamut added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jun 15, 2021
@plamut
plamut merged commit 7597604 into googleapis:master Jun 15, 2021
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jun 15, 2021
@plamut
plamut deleted the iss-222 branch June 15, 2021 18:02
parthea added a commit that referenced this pull request Jul 17, 2021
@parthea
pull in synth.py changes from #299
c842cf0
plamut pushed a commit that referenced this pull request Jul 19, 2021
@parthea @gcf-owl-bot
chore: migrate to owl bot (#411)
232bff3
* chore: migrate to owl bot

* chore: copy files from googleapis-gen 40278112d2922ec917140dcb5cc6d5ef2923aeb2

* chore: run the post processor

* pull in synth.py changes from #299

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* .github/use gcr.io/cloud-devrel-public-resources/owlbot-python post processor image

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/master/packages/owl-bot/README.md

* fix owlbot.py replacement

* Copy generated code from googleapis-gen

* Work around gapic generator docstring bug

* fix: require google-api-core >= 1.26.0

* Work around gapic generator docstring bug

* fix(deps): add packaging requirement

* revert .coveragerc

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
@release-please release-please Bot mentioned this pull request Aug 11, 2022
chore(main): release 2.13.6 #761
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@pradn pradn Awaiting requested review from pradn
1 more reviewer
@jimfulton jimfulton jimfulton approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Allow retry and timeout settings on the publisher client

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@plamut @cguardia @jimfulton @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.