當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。