-
Notifications
You must be signed in to change notification settings - Fork 120
Treat exceptions accessing GCE credential cache file as a cache miss #140
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
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 |
|---|---|---|
|
|
@@ -302,6 +302,11 @@ def _CheckCacheFileForMatch(self, cache_filename, scopes): | |
| if (creds['scopes'] in | ||
| (None, cached_creds['scopes'])): | ||
| scopes = cached_creds['scopes'] | ||
| except KeyboardInterrupt: | ||
| raise | ||
| except: # pylint: disable=bare-except | ||
| # Treat exceptions as a cache miss. | ||
| pass | ||
| finally: | ||
| cache_file.unlock_and_close() | ||
| return scopes | ||
|
|
@@ -331,6 +336,11 @@ def _WriteCacheFile(self, cache_filename, scopes): | |
| # If it's not locked, the locking process will | ||
| # write the same data to the file, so just | ||
| # continue. | ||
| except KeyboardInterrupt: | ||
| raise | ||
| except: # pylint: disable=bare-except | ||
|
Contributor
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. Do we care to add any unit tests?
Contributor
Author
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. It would require mocking locked_file which was removed from more recent versions of oauth2client; this code is simple enough that I'd prefer not to unless you object. |
||
| # Treat exceptions as a cache miss. | ||
| pass | ||
| finally: | ||
| cache_file.unlock_and_close() | ||
|
|
||
|
|
||
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.
Is it not possible to list specific exceptions we care to skip. This would also supress Ctrl-C.
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.
Sure, do you have any other suggestions beyond KeyboardInterrupt?