fs.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:dlmanager 作者: parkouss 项目源码 文件源码
def _call_windows_retry(func, args=(), retry_max=5, retry_delay=0.5):
    """
    It's possible to see spurious errors on Windows due to various things
    keeping a handle to the directory open (explorer, virus scanners, etc)
    So we try a few times if it fails with a known error.
    """
    retry_count = 0
    while True:
        try:
            func(*args)
        except OSError as e:
            # Error codes are defined in:
            # http://docs.python.org/2/library/errno.html#module-errno
            if e.errno not in (errno.EACCES, errno.ENOTEMPTY):
                raise

            if retry_count == retry_max:
                raise

            retry_count += 1

            LOG.info('%s() failed for "%s". Reason: %s (%s). Retrying...',
                     func.__name__, args, e.strerror, e.errno)
            time.sleep(retry_delay)
        else:
            # If no exception has been thrown it should be done
            break
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号