示例#1
0
文件: drive.py 项目: P403n1x87/erwin
 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)
示例#2
0
文件: flow.py 项目: P403n1x87/erwin
 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
示例#3
0
文件: drive.py 项目: P403n1x87/erwin
    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)
示例#4
0
文件: local.py 项目: P403n1x87/erwin
 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