minc_tools.py 文件源码

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

项目:nist_mni_pipelines 作者: vfonov 项目源码 文件源码
def cache(self,name,suffix=''):
        """Allocate a name in cache, if cache was setup
        also lock the file , so that another process have to wait before using the same file name

        Important: call unlock() on result
        """
        #TODO: something more clever here?
        fname=''
        if self.work_dir is not None:
            fname=self.cache_dir+os.sep+name+suffix
            lock_name=fname+'.lock'
            f=self._locks[lock_name]=open(lock_name, 'a')
            fcntl.lockf(f.fileno(), fcntl.LOCK_EX )
        else:
            fname=self.tmp(name+suffix)

        return fname
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号