lockfile.py 文件源码

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

项目:solaris-ips 作者: oracle 项目源码 文件源码
def unlock(self):
                """Unlocks the LockFile."""

                if self._fileobj:
                        # To avoid race conditions with the next caller
                        # waiting for the lock file, it is simply
                        # truncated instead of removed.
                        try:
                                fcntl.lockf(self._fileobj, fcntl.LOCK_UN)
                                self._fileobj.truncate(0)
                                self._fileobj.close()
                                self._lock.release()
                        except EnvironmentError:
                                # If fcntl, or the file operations returned
                                # an exception, drop the lock. Do not catch
                                # the exception that could escape from
                                # releasing the lock.
                                self._lock.release()
                                raise
                        finally:
                                self._fileobj = None
                else:
                        if self._provide_mutex:
                                assert not self._lock.locked
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号