Acquire the lock.
350347
def acquire(self):
        """"""
        self.lease = self.client.lease(self.ttl)

        base64_key = _encode(self.key)
        base64_value = _encode(self._uuid)
        txn = {
            'compare': [{
                'key': base64_key,
                'result': 'EQUAL',
                'target': 'CREATE',
                'create_revision': 0
            }],
            'success': [{
                'request_put': {
                    'key': base64_key,
                    'value': base64_value,
                    'lease': self.lease.id
                }
            }],
            'failure': [{
                'request_range': {
                    'key': base64_key
                }
            }]
        }
        result = self.client.transaction(txn)
        if 'succeeded' in result:
            return result['succeeded']
        return False
358287
public function acquire()
    {
        if (!$this->_object->isSaved()) {
            throw new LockingException("Can't lock unsaved objects");
        }

        $finder = \Pheasant::instance()->finderFor($this->_object);

        return $freshObject = $finder
            ->find($this->_object->className(), $this->_object->identity()->toCriteria())
            ->lock($this->_clause)
            ->one()
            ;
    }
621826
def acquire_nix(lock_file):  # pragma: no cover
    """"""
    fd = os.open(lock_file, OPEN_MODE)

    try:
        fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
    except (IOError, OSError):
        os.close(fd)
    else:
        return fd
51073
def acquire(self):
        
        self._fd = open(self._path, mode='w+')
        os.chmod(self._path, 0o660)
        fcntl.flock(self._fd, self._op)
119095
def get(self,oid):
		""""""
		try:
			self.lock.acquire()
			if oid not in self.data:
				return "NONE"
			else:
				return self.base_oid + oid + '\n' + self.data[oid]['type'] + '\n' +	str(self.data[oid]['value'])
		finally:
			self.lock.release()
875632
public final void acquire() {
		boolean cont = true;

		while (cont) {
			try {
				cont = false;
				this.acquire(-1);
			} catch (RuntimeException te) {
				cont = true;
			}
		}
	}
1224775
public T acquire() {
        T t = pool.poll();
        if (t == null) {
            t = create();
            ++count;
        }
        ++requests;
        // log();
        return t;
    }
1079598
def acquire(self):
        
        
        if self.timeout is not None:
            sleep_intervals = int(self.timeout / self.sleep_time)
        else:
            sleep_intervals = float('inf')
        
        while not self.acquire_try_once() and sleep_intervals > 0:
            time.sleep(self.sleep_time)
            sleep_intervals -= 1
        
        if not self.is_locked_by_me():
            raise util.io.filelock.general.FileLockTimeoutError(self.lock_filename, self.timeout)
315985
def release_lock():
    """"""
    get_lock.n_lock -= 1
    assert get_lock.n_lock >= 0
    # Only really release lock once all lock requests have ended.
    if get_lock.lock_is_enabled and get_lock.n_lock == 0:
        get_lock.start_time = None
        get_lock.unlocker.unlock()
722923
private function acquireLock()
    {
        $this->logger->info('Acquire lock file.');

        if (!$this->lock->lock()) {
            $locked = false;
            $retry  = 3;
            // Try up to 3 times to acquire with short delay in between.
            while ($retry > 0) {
                usleep(1000);
                if ($locked = $this->lock->lock()) {
                    break;
                }
                $retry--;
            }
            if (!$locked) {
                $this->logger->error('Could not acquire lock file.');
                throw new \RuntimeException(
                    'Another task appears to be running. If this is not the case, please remove the lock file.'
                );
            }
        }
    }
239969
def acquire_lock(path: str, blocking: bool) -> Generator[Optional[int], None, None]:
    """"""
    try:
        with open(path, "w+") as lockfile:
            if not blocking:
                lock_command = fcntl.LOCK_EX | fcntl.LOCK_NB
            else:
                lock_command = fcntl.LOCK_EX

            fcntl.lockf(lockfile.fileno(), lock_command)
            yield lockfile.fileno()
            fcntl.lockf(lockfile.fileno(), fcntl.LOCK_UN)

    except FileNotFoundError:
        yield
881688
def acquire(self, key):
        """"""
        if _debug: DeviceInfoCache._debug("acquire %r", key)

        if isinstance(key, int):
            device_info = self.cache.get(key, None)

        elif not isinstance(key, Address):
            raise TypeError("key must be integer or an address")

        elif key.addrType not in (Address.localStationAddr, Address.remoteStationAddr):
            raise TypeError("address must be a local or remote station")

        else:
            device_info = self.cache.get(key, None)

        if device_info:
            if _debug: DeviceInfoCache._debug("    - reference bump")
            device_info._ref_count += 1

        if _debug: DeviceInfoCache._debug("    - device_info: %r", device_info)

        return device_info
379851
def acquire(self, block=True):
        """"""
        while True:
            # Try to set the lock
            if self.redis.set(self.name, self.value, px=self.timeout, nx=True):
                # It's ours until the timeout now
                return True
            # Lock is taken
            if not block:
                return False
            # If blocking, try again in a bit
            time.sleep(self.sleep)
1090210
def acquire(self, blocking=True, timeout=None):
        
        logger.debug("Getting %r ...", self._name)

        if self._held:
            raise AlreadyAcquired("Already acquired from this Lock instance.")

        if not blocking and timeout is not None:
            raise TimeoutNotUsable("Timeout cannot be used if blocking=False")

        timeout = timeout if timeout is None else int(timeout)
        if timeout is not None and timeout <= 0:
            raise InvalidTimeout("Timeout (%d) cannot be less than or equal to 0" % timeout)

        if timeout and self._expire and timeout > self._expire:
            raise TimeoutTooLarge("Timeout (%d) cannot be greater than expire (%d)" % (timeout, self._expire))

        busy = True
        blpop_timeout = timeout or self._expire or 0
        timed_out = False
        while busy:
            busy = not self._client.set(self._name, self._id, nx=True, ex=self._expire)
            if busy:
                if timed_out:
                    return False
                elif blocking:
                    timed_out = not self._client.blpop(self._signal, blpop_timeout) and timeout
                else:
                    logger.debug("Failed to get %r.", self._name)
                    return False

        logger.debug("Got lock for %r.", self._name)
        if self._lock_renewal_interval is not None:
            self._start_lock_renewer()
        return True
829626
def unlock(self):
        """"""
        if self.__lock_state:
            data = self._controller.command(self._id, 'door_unlock',
                                            wake_if_asleep=True)
            if data['response']['result']:
                self.__lock_state = False
            self.__manual_update_time = time.time()
1047375
def _ProcessLockAcquired(self):
        """"""
        try:
            is_locked = self._process_lock.acquire(timeout=self._lock_timeout)
            yield is_locked
        finally:
            if is_locked:
                self._process_lock.release()
951480
private static Object getLockObject(Object key) {
    int hc = key.hashCode();
    return KEY_LOCKS[hc & KEY_LOCKS_MASK];
  }