How to use the portalocker.LOCK_UN function in portalocker

To help you get started, we’ve selected a few portalocker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github thought-machine / please / tools / please_pex / pex / pex_main.py View on Github external
def pex_lockfile(basepath, uniquedir):
        # Acquire the lockfile.
        lockfile_path = os.path.join(basepath, '.lock-%s' % uniquedir)
        lockfile = open(lockfile_path, "a+")
        # Block until we can acquire the lockfile.
        portalocker.lock(lockfile, portalocker.LOCK_EX)
        lockfile.seek(0)
        yield lockfile
        portalocker.lock(lockfile, portalocker.LOCK_UN)
github webrecorder / pywb / pywb / recorder / multifilewarcwriter.py View on Github external
def _close_file(self, fh):
        try:
            if os.name != 'nt':
                portalocker.lock(fh, portalocker.LOCK_UN)
            return True
        except Exception as e:
            print(e)
            return False
        finally:
            no_except_close(fh)
github awslabs / sockeye / sockeye / utils.py View on Github external
def __exit__(self, exc_type, exc_val, exc_tb):
        if self.gpu_id is not None:
            logger.info("Releasing GPU {}.".format(self.gpu_id))
        if self.lock_file is not None:
            if self._acquired_lock:
                portalocker.lock(self.lock_file, portalocker.LOCK_UN)
            self.lock_file.close()
            os.remove(self.lockfile_path)