load.py 文件源码

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

项目:raptiformica 作者: vdloo 项目源码 文件源码
def config_cache_lock():
    """
    Obtain the config cache lock, perform the code
    in the context and then let the lock go.
    :yield None
    :return None:
    """
    with open(conf().CONFIG_CACHE_LOCK, 'w+') as lock:
        try:
            log.debug(
                "Getting config cache lock. "
                "If this blocks forever, try deleting file "
                "{} and restart the process.".format(conf().CONFIG_CACHE_LOCK)
            )
            flock(lock, LOCK_EX)  # Blocks until lock becomes available
            yield
        finally:
            log.debug("Releasing the config cache lock")
            flock(lock, LOCK_UN)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号