Check if the lockfile is in the calculation directory.
        It is removed by the script at the end regardless of the
        success of the calculation. This is totally tied to
        implementation and you need to implement your own scheme!
427985
def calc_finished(self):
        '''
        
        '''
        #print_stack(limit=5)
        if not self.calc_running :
            #print('Calc running:',self.calc_running)
            return True
        else:
            # The calc is marked as running check if this is still true
            # We do it by external scripts. You need to write these
            # scripts for your own system.
            # See examples/scripts directory for examples.
            with work_dir(self.working_dir) :
                o=check_output(['check-job'])
            #print('Status',o)
            if o[0] in b'R' :
                # Still running - we do nothing to preserve the state
                return False
            else :
                # The job is not running maybe it finished maybe crashed
                # We hope for the best at this point ad pass to the
                # Standard update function
                return True
705734
private static boolean isSharedFileLockTable() {
        if (!propertyChecked) {
            synchronized (FileChannelImpl.class) {
                if (!propertyChecked) {
                    /*
                    String value = AccessController.doPrivileged(
                        new GetPropertyAction(
                            "sun.nio.ch.disableSystemWideOverlappingFileLockCheck"));
                    */
                    String value =
                        System.getProperty("sun.nio.ch.disableSystemWideOverlappingFileLockCheck");
                    isSharedFileLockTable = ((value == null) || value.equals("false"));
                    propertyChecked = true;
                }
            }
        }
        return isSharedFileLockTable;
    }
748212
def lock_pid(self):
        
        
        if os.path.exists(self.lock_filename):
            return int(open(self.lock_filename).read())
        else:
            return None
86192
def _recoverfile_from_lockfile(self, lockfile):
        
        # Require that the lock file path be absolute, or at least relative
        # and starting with the pipeline output folder.
        if not (os.path.isabs(lockfile) or lockfile.startswith(self.outfolder)):
            lockfile = self._make_lock_path(lockfile)
        return lockfile.replace(LOCK_PREFIX, "recover." + LOCK_PREFIX)
651203
boolean checkFileProgress(INodeFile v, boolean checkall) 
    throws IOException {
    INode.enforceRegularStorageINode(v, 
        "checkFileProgress is not supported for non-regular files");
    if (checkall) {
      //
      // check all blocks of the file.
      //
      int closeFileReplicationMin =
        Math.min(v.getReplication(), this.minCloseReplication);
      for (Block block : v.getBlocks()) {
        if (!checkBlockProgress(v, block, closeFileReplicationMin)) {
          return false;
        }
      }
      return true;
    } else {
      //
      // check the penultimate block of this file
      //
      Block b = v.getStorage().getPenultimateBlock();
      return checkBlockProgress(v, b, minReplication);
    }
  }
726417
def _unlock_cache(w_lock):
    '''
    
    '''
    if not os.path.exists(w_lock):
        return
    try:
        if os.path.isdir(w_lock):
            os.rmdir(w_lock)
        elif os.path.isfile(w_lock):
            os.unlink(w_lock)
    except (OSError, IOError) as exc:
        log.trace('Error removing lockfile %s: %s', w_lock, exc)
1369562
def make(self):
        
        try:
                
            # Create the lock file
            self.mkfile(self.lock_file)
        except Exception as e:
            self.die('Failed to generate lock file: {}'.format(str(e)))
1048462
function getCurrentFileSize(counter, timeout, cb) {
  var fd = fs.openSync(__filename, 'r');

  console.log("Trying to aquire lock for the %s time", counter);

  fs.flock(fd, 'exnb', function(err) {
    if (err) {
      return console.log("Couldn't lock file", counter);
    }

    console.log('Aquired lock', counter);

    // unlock after `timeout`
    setTimeout(function() {
      fs.flock(fd, 'un', function(err) {
        if (err) {
          return console.log("Couldn't unlock file", counter);
        }

        if (cb) { cb(); }
      });
    }, timeout);
  });
}
1196706
def lock(self):
        """"""
        data = self.data
        data['_meta']['hash'] = {"sha256": self.hash}
        data['_meta']['pipfile-spec'] = 6
        return json.dumps(data, indent=4, separators=(',', ': '))
380970
function checkFile(fileName, contents) {
    forbiddenCode.forEach(function(forbiddenItem) {
        if (contents.indexOf(forbiddenItem) > -1) {
            /* eslint-disable */
            console.log('FAILURE: '.red + 'You left a '.reset + forbiddenItem.yellow + ' in '.reset + fileName.cyan);
            /* eslint-enable */
            errorFound = true;
        }
    });
}
201930
def _lockfile(self):
        """"""
        pfile = pipfile.load(self.pipfile_location, inject_env=False)
        lockfile = json.loads(pfile.lock())
        for section in ("default", "develop"):
            lock_section = lockfile.get(section, {})
            for key in list(lock_section.keys()):
                norm_key = pep423_name(key)
                lockfile[section][norm_key] = lock_section.pop(key)
        return lockfile
249812
def _obtain_lock_or_raise(self):
        """"""
        if self._has_lock():
            return
        lock_file = self._lock_file_path()
        if os.path.isfile(lock_file):
            raise IOError("Lock for file %r did already exist, delete %r in case the lock is illegal" % (self._file_path, lock_file))

        try:
            fd = os.open(lock_file, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0)
            os.close(fd)
        except OSError,e:
            raise IOError(str(e))

        self._owns_lock = True
962339
function lock(from, to) {
  from = fis.file.wrap(from).realpath;
  to = fis.file.wrap(to).realpath;

  lockedMap[to] = from;
}
423805
protected static function lock()
    {
        $fd = fopen(static::$_startFile, 'r');
        if (!$fd || !flock($fd, LOCK_EX)) {
            static::log("Workerman[".static::$_startFile."] already running");
            exit;
        }
    }
54013
public static FileLocker getLock(File lockFile) {
        lockFile.getParentFile().mkdirs();
        if (!lockFile.exists()) {
            try {
                IOHelper.write(lockFile, "I have the lock!");
                lockFile.deleteOnExit();
                return new FileLocker(lockFile);
            } catch (IOException e) {
                // Ignore
            }
        }
        return null;

    }
490307
function getAddMtime(file, done) {
    fs.stat(path.join(source, file), addMtime);


    /**
     * Adds `stats.mtime` of `file` to its metadata.
     *
     * @param {Error} err
     * @param {fs.Stats} stats
     * @api private
     */

    function addMtime(err, stats) {
      if (err) {
        // Skip elements of `files` that don't point to existing files.
        // This can happen if some other Metalsmith plugin does something
        // strange with `files`.
        if (err.code === 'ENOENT') {
          debug('file %s not found', file);
          return done();
        }
        return done(err);
      }

      debug('mtime of file %s is %s', file, stats.mtime);
      files[file].mtime = stats.mtime;
      done();
    }
  }
1326937
def isHeld(self):
        '''
            
        '''
        if not os.path.exists(self.lockPath):
            return False
        
        try:
            mtime = os.stat(self.lockPath).st_mtime
        except FileNotFoundError as e:
            return False
        
        if self.__checkExpiration(mtime):
            return False

        return True