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: add timeout parameter to AuthorizedSession.request() by plamut · Pull Request #406 · googleapis/google-auth-library-python

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

Conversation

@plamut

@plamut plamut commented Dec 10, 2019 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Fixes #396.

This PR is a replacement for #397 that caused a bug in at least one downstream librariy. It contains additional logic that correctly handles timeouts passed as a tuple (the requests library support two different timeout forms - link).

The first commit is identical to the original PR, and all new logic is contained in the commit(s) that follow.

MIND:
A downstream library that is timeout-sensitive might still be affected by the change, because the new explicit timeout parameter changes the semantics of AuthorizedSession.request() . The timeout represents the total allowed time for all requests made behind the scenes (e.g. credentials refresh attempts), as opposed to a previous per-request timeout.

The rationale behind this, however, is that libraries such as BigQuery use AuthorizedSession as their transport, and consider auth_session.request(...) a single operation, even though the latter might consist of multiple requests.

P.S.: On the other hand, and if I read the code correctly, any exiting timeout argument (passed via **kwargs) already applied to the "main" request only, and not to the credentials-related requests. The initial self.credentials.before_request() call had a hard-coded timeout of 120 seconds, while any subsequent credentials refresh calls used self._refresh_timeout, which is actually None by default.

Sorry, something went wrong.

Uh oh!

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

All reactions
plamut added 2 commits December 9, 2019 08:09
@plamut
feat: add timeout to AuthorisedSession.request()
cc243e4
@plamut
Add suport for timeout as a tuple to timeout guard
3cca138
The `request.Request` class also accepts a timeout as a pair
(connect_timeout, read_timeout), and some downstream libraries use
this form.

This commit makes sure that the timeout logic correctly handles
timeouts as a two-tuple.

See also:
https://2.python-requests.org/en/master/user/advanced/#timeouts
@plamut
plamut requested a review from busunkim96 December 10, 2019 14:38
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 10, 2019
@plamut plamut mentioned this pull request Dec 10, 2019
feat(bigquery): add timeout parameter to QueryJob.done() method googleapis/google-cloud-python#9875
Merged
5 tasks done
@busunkim96
busunkim96 requested a review from tswast December 11, 2019 22:44
busunkim96
busunkim96 approved these changes Dec 11, 2019
View reviewed changes

@busunkim96 busunkim96 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.

LGTM. @tswast would you also be able to review this?

Sorry, something went wrong.

Uh oh!

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

All reactions
tswast
tswast approved these changes Dec 12, 2019
View reviewed changes
@tswast
tswast merged commit d86d7b8 into googleapis:master Dec 12, 2019
@plamut plamut mentioned this pull request Jan 16, 2020
Make a clear distinction between the transport timeout and the total method time timeout #423
Closed
@yoshi-automation yoshi-automation mentioned this pull request Jan 22, 2020
[CHANGE ME] Re-generated to pick up changes in the API or client library generator. #429
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

2 more reviewers
@tswast tswast tswast approved these changes
@busunkim96 busunkim96 busunkim96 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

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.

Add timeout parameter to AuthorizedSession.request()

Uh oh!

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

4 participants

@plamut @tswast @busunkim96 @googlebot
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.