_logs.py 文件源码

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

项目:porcupine 作者: Akuli 项目源码 文件源码
def _lock(fileno):
    """Try to lock a file. Return True on success."""
    # closing the file unlocks it, so we don't need to unlock here
    if platform.system() == 'Windows':
        try:
            msvcrt.locking(fileno, msvcrt.LK_NBLCK, 10)
            return True
        except PermissionError:
            return False
    else:
        try:
            fcntl.lockf(fileno, fcntl.LOCK_EX | fcntl.LOCK_NB)
            return True
        # the docs recommend catching both of these
        except (BlockingIOError, PermissionError):
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号