当前位置: 首页>>代码示例>>Python>>正文


Python fcntl.LOCK_UN属性代码示例

本文整理汇总了Python中fcntl.LOCK_UN属性的典型用法代码示例。如果您正苦于以下问题:Python fcntl.LOCK_UN属性的具体用法?Python fcntl.LOCK_UN怎么用?Python fcntl.LOCK_UN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在fcntl的用法示例。


在下文中一共展示了fcntl.LOCK_UN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: release

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def release(self):
        """Release the lock by deleting `self.lockfile`."""
        if not self._lock.is_set():
            return False

        try:
            fcntl.lockf(self._lockfile, fcntl.LOCK_UN)
        except IOError:  # pragma: no cover
            pass
        finally:
            self._lock.clear()
            self._lockfile = None
            try:
                os.unlink(self.lockfile)
            except (IOError, OSError):  # pragma: no cover
                pass

            return True 
开发者ID:TKkk-iOSer,项目名称:wechat-alfred-workflow,代码行数:20,代码来源:util.py

示例2: __exit__

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def __exit__(self, exc_type, exc_value, traceback):
      # Flush any buffered data to disk. This is needed to prevent race
      # condition which happens from the moment of releasing file lock
      # till closing the file.
      self._fo.flush()

      try:
        if sys.platform == 'win32':
          self._fo.seek(0)
          msvcrt.locking(self._fo.fileno(), msvcrt.LK_UNLCK, 1)
        else:
          fcntl.flock(self._fo.fileno(), fcntl.LOCK_UN)
      finally:
        self._fo.close()

      return exc_value is None 
开发者ID:google,项目名称:gtest-parallel,代码行数:18,代码来源:gtest_parallel.py

示例3: unlock_file

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def unlock_file(self, name):
        f = self.locks.get(name)
        if not f:
            self.log(DEBUG, "unlock_file: %s not locked", name)
            return

        # XXXX does this create a possible race condition?
        if 0:
            try:
                os.unlink(name)
            except:
                pass
        status = fcntl.lockf(f, fcntl.LOCK_UN)
        f.close()
        del self.locks[name]
        return status 
开发者ID:rucio,项目名称:rucio,代码行数:18,代码来源:pcache.py

示例4: udpate_status

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def udpate_status(status_file_path, module_data, module):
	lock_file_path = "{}.lock".format(status_file_path)
	while True:
		status_file_lock = open(lock_file_path, 'r')
		try:
			fcntl.flock(status_file_lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
			with open(status_file_path, "r+") as status_file:
				data = json.load(status_file)
				status_file.seek(0)
				data[module].update(module_data)
				json.dump(data, status_file)
			fcntl.flock(status_file_lock, fcntl.LOCK_UN)
			return
		except:
			time.sleep(0.1)
		status_file_lock.close() 
开发者ID:BishopFox,项目名称:IDontSpeakSSL,代码行数:18,代码来源:utils.py

示例5: __exit__

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def __exit__(self, exc_type, exc_val, traceback):
        if (exc_type is None and self._data_written):
            os.replace(self._temp_file_path, self._config_file)
            os.chmod(self._config_file, 0o660)
            shutil.chown(self._config_file, user=USER, group=GROUP)
        else:
            self._temp_file.close()
            os.unlink(self._temp_file_path)
            if (self._Log):
                self._Log.error(f'configuration manager exiting with error: {exc_val}')

        # releasing lock for purposes specified in flock(1) man page under -u (unlock)
        fcntl.flock(self._config_lock, fcntl.LOCK_UN)
        self._config_lock.close()
        if (self._Log):
            self._Log.debug(f'file lock released for {self._file_name}')

        if (exc_type is not ValidationError):
            return True

    #will load json data from file, convert it to a python dict, then returned as object 
开发者ID:DOWRIGHTTV,项目名称:dnxfirewall-cmd,代码行数:23,代码来源:dnx_file_operations.py

示例6: do_write

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def do_write(self, obuf):
        my_flock = flock
        try:
            my_flock(self.log, LOCK_EX)
        except IOError as e:
            # Catch ENOTSUP
            if e.args[0] != 45:
                raise e
            my_flock = lambda x, y: None
        try:
            self.log.write(obuf)
            self.log.flush()
        except:
            pass
        my_flock(self.log, LOCK_UN) 
开发者ID:sippy,项目名称:rtp_cluster,代码行数:17,代码来源:SipLogger.py

示例7: unlock_and_close

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def unlock_and_close(self):
      """Close and unlock the file using the fcntl.lockf primitive."""
      if self._locked:
        fcntl.lockf(self._fh.fileno(), fcntl.LOCK_UN)
      self._locked = False
      if self._fh:
        self._fh.close() 
开发者ID:mortcanty,项目名称:earthengine,代码行数:9,代码来源:locked_file.py

示例8: release

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def release(self):
        fcntl.flock(self.handle, fcntl.LOCK_UN) 
开发者ID:cea-hpc,项目名称:pcocc,代码行数:4,代码来源:Config.py

示例9: __exit__

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def __exit__(self, exc_type, exc_value, traceback):
        if self._lock_file:
            fcntl.lockf(self._lock_file.fileno(), fcntl.LOCK_UN)
            self._lock_file.close() 
开发者ID:PrivacyScore,项目名称:PrivacyScore,代码行数:6,代码来源:utils.py

示例10: lock

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def lock():
    # Since Local Mode uses the same port for serving, we need a lock in order
    # to allow concurrent test execution.
    local_mode_lock_fd = open(LOCK_PATH, 'w')
    local_mode_lock = local_mode_lock_fd.fileno()

    fcntl.lockf(local_mode_lock, fcntl.LOCK_EX)

    try:
        yield
    finally:
        time.sleep(5)
        fcntl.lockf(local_mode_lock, fcntl.LOCK_UN) 
开发者ID:aws,项目名称:sagemaker-pytorch-training-toolkit,代码行数:15,代码来源:local_mode_utils.py

示例11: unlock

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def unlock(f):
            ret = fcntl.flock(_fd(f), fcntl.LOCK_UN)
            return (ret == 0) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:5,代码来源:locks.py

示例12: _unlock_file

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def _unlock_file(f):
    """Unlock file f using lockf and dot locking."""
    if fcntl:
        fcntl.lockf(f, fcntl.LOCK_UN)
    if os.path.exists(f.name + '.lock'):
        os.remove(f.name + '.lock') 
开发者ID:glmcdona,项目名称:meddle,代码行数:8,代码来源:mailbox.py

示例13: _release

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def _release(self):
        # Do not remove the lockfile:
        #
        #   https://github.com/benediktschmitt/py-filelock/issues/31
        #   https://stackoverflow.com/questions/17708885/flock-removing-locked-file-without-race-condition
        fd = self._lock_file_fd
        self._lock_file_fd = None
        fcntl.flock(fd, fcntl.LOCK_UN)
        os.close(fd)
        return None

# Soft lock
# ~~~~~~~~~ 
开发者ID:a4k-openproject,项目名称:a4kScrapers,代码行数:15,代码来源:filelock.py

示例14: read_release

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def read_release(self):
		with self.__local.f as f:
			self.__local.f = None
			lockf(f, LOCK_UN) 
开发者ID:OpenMTC,项目名称:OpenMTC,代码行数:6,代码来源:RWLock.py

示例15: unlock_file

# 需要导入模块: import fcntl [as 别名]
# 或者: from fcntl import LOCK_UN [as 别名]
def unlock_file(lockfile):
    fcntl.lockf(lockfile, fcntl.LOCK_UN)
    lockfile.close()


# Utility functions for dealing with external processes 
开发者ID:avocado-framework,项目名称:avocado-vt,代码行数:8,代码来源:utils_misc.py


注:本文中的fcntl.LOCK_UN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。