Lock the Sesame. Return True on success, else False.
961034
def lock(self):
        """"""
        endpoint = API_SESAME_CONTROL_ENDPOINT.format(self.device_id)
        payload = {'type': 'lock'}
        response = self.account.request('POST', endpoint, payload=payload)
        if response is None:
            return False
        if response.status_code == 200 or response.status_code == 204:
            return True
        return False
361655
def lock(self):
        """"""
        success = self.set_status(CONST.STATUS_LOCKCLOSED_INT)

        if success:
            self._json_state['status'] = CONST.STATUS_LOCKCLOSED

        return success
768794
async def lock(self, container = None):
        ""
        if container is None:
            container = RoutineContainer.get_container(self.scheduler)
        if self.locked:
            pass
        elif self.lockroutine:
            await LockedEvent.createMatcher(self)
        else:
            await container.wait_for_send(LockEvent(self.context, self.key, self))
            self.locked = True
566914
public boolean tryLock(String key, String request) {
        //get connection
        Object connection = getConnection();
        String result ;
        if (connection instanceof Jedis){
            result =  ((Jedis) connection).set(lockPrefix + key, request, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, 10 * TIME);
            ((Jedis) connection).close();
        }else {
            result = ((JedisCluster) connection).set(lockPrefix + key, request, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, 10 * TIME);

        }

        if (LOCK_MSG.equals(result)) {
            return true;
        } else {
            return false;
        }
    }
1145156
def valid_lock(self):
        

        lock_pid = self.get_lock_pid()

        # If we're unable to get lock_pid
        if lock_pid is None:
            return False

        # this is our process
        if self._pid == lock_pid:
            return True

        # it is/was another process
        # see if it is running
        try:
            os.kill(lock_pid, 0)
        except OSError:
            self.release()
            return False

        # it is running
        return True
519832
function lock()
    {
        if ( $fp = $this->fp() )
        {
            if ( flock( $fp, LOCK_EX ) )
            {
                $this->clearMeta();
                $this->setMeta( 'timestamp', time() );
                return true;
            }
        }
        return false;
    }
1181767
async def is_locked(self, resource):
        

        successes = await asyncio.gather(*[
            i.is_locked(resource) for
            i in self.instances
        ], return_exceptions=True)
        successful_sets = sum(s is True for s in successes)

        locked = True if successful_sets >= int(len(self.instances) / 2) + 1 else False

        return locked
539382
protected function lock() {

        $this->db->lockTable($this->getTable());
        $this->locked = true;

        return true;
    }
222202
def lock(self, instance_id):
        '''
        
        '''
        nt_ks = self.compute_conn
        response = nt_ks.servers.lock(instance_id)
        return True
58436
public boolean hasCorrectLockstate() {

        org.opencms.lock.CmsLock lock = null;
        try {
            // get the lock state for the current resource
            lock = getCms().getLock(getParamResource());
        } catch (CmsException e) {
            // error getting lock state, log the error and return false
            LOG.error(e.getLocalizedMessage(getLocale()), e);
            return false;
        }
        // check if auto lock feature is enabled
        boolean autoLockFeature = lock.isNullLock() && OpenCms.getWorkplaceManager().autoLockResources();
        return autoLockFeature || lock.isExclusive() || lock.isInherited();
    }
375561
def hasLock(self):
        '''
            
        '''
        # If we don't hold it currently, return False
        if self.held is False:
            return False
        
        # Otherwise if we think we hold it, but it is not held, we have lost it.
        if not self.isHeld:
            self.acquiredAt = None
            self.held = False
            return False

        # Check if we expired
        if self.__checkExpiration(self.acquiredAt):
            self.acquiredAt = None
            self.held = False
            return False


        return True
203386
private synchronized boolean tryServerLock() throws IOException {
        if (!lockFile.exists() || lockFileChannel == null)
            return false;

        boolean lockObtained = true;

        try {
            serverLock = lockFileChannel.tryLock();

            // if server lock is not valid, it could not be obtained
            if (serverLock == null || !serverLock.isValid())
                lockObtained = false;
        } catch (OverlappingFileLockException e) {
            lockObtained = false;
        } catch (IOException e) {
            lockObtained = false;
        } finally {
            // make sure we release so the other process can obtain the lock file
            if (serverLock != null)
                serverLock.release();
        }

        return lockObtained;
    }
418563
def _locked(func):
    """"""
    def _locking(self, *args, **kwargs):
        try:
            self.lock()
            return func(self, *args, **kwargs)
        finally:
            self.unlock()
    return _locking
533149
boolean isLocked(final DeviceProxy deviceProxy) throws DevFailed {
        final LockerInfo info = getLockerInfo(deviceProxy);
        return info.isLocked();
    }
1128193
private static void lockBoth(Lock sourceWriteLock, Lock destWriteLock) {
    while (true) {
      sourceWriteLock.lock();
      if (destWriteLock.tryLock()) {
        return;
      } else {
        sourceWriteLock.unlock();
      }

      destWriteLock.lock();
      if (sourceWriteLock.tryLock()) {
        return;
      } else {
        destWriteLock.unlock();
      }
    }
  }
841879
void tryUnlockCurrent() {

        if ((m_lockAction != null) && m_lockAction.getChange().equals(CmsLockActionRecord.LockChange.locked)) {
            try {
                A_CmsUI.getCmsObject().unlockResource(m_currentResource);
            } catch (CmsException e) {
                e.printStackTrace();
            }
        }
    }
1363919
async def is_locked(self, resource):
        

        with await self.connect() as redis:
            lock_identifier = await redis.get(resource)
        if lock_identifier:
            return True
        else:
            return False