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

fix: add timeout for auth requests #1616

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion google/auth/transport/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ class Request(transport.Request):
.. automethod:: __call__
"""

def __init__(self, session=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Checkout how AuthorizedSession is handling the timeouts and see if we can adapt same. I see something about TimeGuards there as well.

def __init__(self, session=None, timeout=_DEFAULT_TIMEOUT):
if not session:
session = requests.Session()
self.timeout = timeout

self.session = session

Expand Down Expand Up @@ -184,6 +185,7 @@ def __call__(
"""
try:
_LOGGER.debug("Making request: %s %s", method, url)
timeout = timeout if timeout != _DEFAULT_TIMEOUT else self.timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an edge case where someone sets t1 at the object level but they want default timeout for a specific request. They have no way of doing that now. Even if default timeout is passed to call explicitly, it is going to use the object level one.

response = self.session.request(
method, url, data=body, headers=headers, timeout=timeout, **kwargs
)
Expand Down