From ff33c81bbd4efc23cadbb089b090cb9dc28c4fde Mon Sep 17 00:00:00 2001 From: Travis Hobrla Date: Tue, 10 Feb 2015 17:47:43 -0800 Subject: [PATCH] Fall back to refreshing credentials if open_and_lock fails with ENOSYS or ENOLCK --- oauth2client/multistore_file.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/oauth2client/multistore_file.py b/oauth2client/multistore_file.py index a2750f3..f4ba4a7 100644 --- a/oauth2client/multistore_file.py +++ b/oauth2client/multistore_file.py @@ -46,6 +46,7 @@ The format of the stored data is like so:: __author__ = 'jbeda@google.com (Joe Beda)' +import errno import json import logging import os @@ -279,7 +280,17 @@ class _MultiStore(object): def _lock(self): """Lock the entire multistore.""" self._thread_lock.acquire() - self._file.open_and_lock() + try: + self._file.open_and_lock() + except IOError as e: + if e.errno == errno.ENOSYS: + logger.warn('File system does not support locking the credentials ' + 'file.') + elif e.errno == errno.ENOLCK: + logger.warn('File system is out of resources for writing the ' + 'credentials file (is your disk full?).') + else: + raise if not self._file.is_locked(): self._read_only = True if self._warn_on_readonly: