def wrapper(*args, **kwargs): try: CONNECTED.wait() return f(*args, **kwargs) except HttpError as e: LOGGER.warning( f"HTTP error {e.resp.status} suppressed after call to {f} with arguments " f"{args}, {kwargs}: {e}" ) except ServerNotFoundError as e: LOGGER.error( f"Cannot call {f} with arguments {args}, {kwargs} at this time. " f"Reason: {e}" ) CONNECTED.clear() CONNECTED.wait() return suppresserror(f)(*args, **kwargs)
def func_wrapper(*args, **kwargs): backoff = delay while True: try: error = False return f(*args, **kwargs) except FSNotReady as e: LOGGER.error(f"A file system is not ready yet: {e}") LOGGER.info( f"A new start attempt will be made in {int(backoff)} seconds" ) sleep(backoff) backoff = min(cap, backoff * ratio) error = True finally: if not error: backoff = delay
def get_changes(self): backoff = 5 while True: LOGGER.trace(f"Getting Drive changes (backoff: {backoff})") try: with STATE_LOCK: yield self._get_changes() backoff = 5 CONNECTED.set() except ServerNotFoundError: backoff *= 1.618 LOGGER.error( f"The Google Drive API is unreachable. Retrying in {int(backoff)} seconds." ) finally: sleep(backoff)
def read(self, path): try: return open(self._abs_path(path), "rb") except (FileNotFoundError, IOError): LOGGER.error(f"Cannot read file {self._abs_path(path)} from {self}") return None