-
Notifications
You must be signed in to change notification settings - Fork 307
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -137,9 +137,10 @@ class Request(transport.Request): | |
.. automethod:: __call__ | ||
""" | ||
|
||
def __init__(self, session=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
||
|
@@ -184,6 +185,7 @@ def __call__( | |
""" | ||
try: | ||
_LOGGER.debug("Making request: %s %s", method, url) | ||
timeout = timeout if timeout != _DEFAULT_TIMEOUT else self.timeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
) | ||
|
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.
Add test to https://github.com/googleapis/google-auth-library-python/blob/main/tests/transport/test_requests.py and maybe also to https://github.com/googleapis/google-auth-library-python/blob/main/tests/test_credentials.py