Return if the connection is currently executing a query or is locked
        by a session that still exists.

        :rtype: bool
541380
def busy(self):
        
        if self.handle.isexecuting():
            return True
        elif self.used_by is None:
            return False
        return not self.used_by() is None
824088
private boolean isLocked(String path) {

        // get lock for path
        CmsRepositoryLockInfo lock = m_session.getLock(path);
        if (lock == null) {
            return false;
        }

        // check if found lock fits to the lock token from request
        //        String currentToken = "<opaquelocktoken:" + generateLockToken(req, lock) + ">";
        //        if (currentToken.equals(parseLockTokenHeader(req))) {
        //            return false;
        //        }

        if (lock.getUsername().equals(m_username)) {
            return false;
        }

        return true;
    }
713002
def is_always_accessible(self):
        
        return self._val[0] == datetime.min and self._val[1] == datetime.max
1184969
def lock(self, fail_on_lock=False, cleanup=False):
        
        return self.connection.lock(self, fail_on_lock, cleanup)
381362
def lock(self):
    """"""
    if hasattr(self, 'session'):
      raise RuntimeError('Dead lock detected. Please do not try to lock the session when it is already locked!')

    if LooseVersion(sqlalchemy.__version__) < LooseVersion('0.7.8'):
      # for old sqlalchemy versions, in some cases it is required to re-generate the engine for each session
      self._engine = sqlalchemy.create_engine("sqlite:///"+self._database)
      self._session_maker = sqlalchemy.orm.sessionmaker(bind=self._engine)

    # create the database if it does not exist yet
    if not os.path.exists(self._database):
      self._create()

    # now, create a session
    self.session = self._session_maker()
    logger.debug("Created new database session to '%s'" % self._database)
    return self.session
16775
def exists(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.exists(index=self._name, **kwargs)
861043
def connected?(klass)
      return false if Process.pid != @process_pid.get
      conn = self.retrieve_connection_pool(klass)
      conn && conn.connected?
    end
369218
def connection(self):
        
        
        self._condition.acquire()
        try:
            if (self._maxconnections and self._connections >= self._maxconnections):
                raise TooManyConnections("%d connections are already equal to the max: %d" % (self._connections, self._maxconnections))
            # connection limit not reached, get a dedicated connection
            try: # first try to get it from the idle cache
                con = self._idle_cache.pop(0)
            except IndexError: # else get a fresh connection
                con = self.new_connection()
            self._connections += 1
        finally:
            self._condition.release()
        return con
351363
public boolean isConnectionStale() {
        if (lastUsedTime == 0)
            return false;

        long currentTime = System.currentTimeMillis();
        long timeSinceLastUse = currentTime - lastUsedTime;
        return (timeSinceLastUse > MAX_KEEPALIVE);
    }
1256809
async def connect(self, connection):
        
        if self._user_connected:
            self._log.info('User is already connected!')
            return

        self._connection = connection
        await self._connect()
        self._user_connected = True
351727
def open(self):
        
        try:
            if self.conn.get_backend_pid():
                return True
        except psycopg2.InterfaceError as e:
            if str(e) == "connection already closed":
                # We already lost our connection. Attempt to reforge it.
                self.__reconnect__()
                if self.conn.get_backend_pid() >= 0:
                    return True # Resets it.
            else:
                raise e
369735
def get_guest_connection_status(self, userid):
        ''''''
        rd = ' '.join(('getvm', userid, 'isreachable'))
        results = self._request(rd)
        if results['rs'] == 1:
            return True
        else:
            return False
1082547
public function isBlocked()
    {
        $ip = $this->getIp();
        $this->deleteAttempts($ip, false);

        // INET_ATON
        $query = "SELECT count(*) FROM {$this->config->table_attempts} WHERE ip = :ip";
        $query_prepared = $this->dbh->prepare($query); // INET_ATON(:ip)
        $query_prepared->execute(['ip' => $ip]);
        $attempts = $query_prepared->fetchColumn();

        if ($attempts < intval($this->config->attempts_before_verify)) {
            return "allow";
        }

        if ($attempts < intval($this->config->attempts_before_ban)) {
            return "verify";
        }

        return "block";
    }
782838
def get(self, session):
        
        idle = self.idle_connections
        if idle:
            connection = idle.pop(0)
            connection.lock(session)
            if self.idle_start:
                with self._lock:
                    self.idle_start = None
            return connection.handle
        raise NoIdleConnectionsError(self.id)
163613
def is_locked(self, request: AxesHttpRequest, credentials: dict = None) -> bool:
        

        if settings.AXES_LOCK_OUT_AT_FAILURE:
            return self.get_failures(request, credentials) >= settings.AXES_FAILURE_LIMIT

        return False
252332
def is_alive(self):
        
        if hasattr(self.device, 'remote_conn'):
            return self.device.remote_conn.transport.is_active() and self._xml_agent_alive
        return False
368389
def is_not_blocked(self, item: str) -> bool:
        
        assert item is not None
        item = self._encode_item(item)
        connection = self.__get_connection()
        key = self.__redis_conf['blacklist_template'].format(item)
        value = connection.get(key)
        if value is None:
            BlackRed.__release_connection(connection)
            return True
        if self.__redis_conf['blacklist_refresh_ttl']:
            connection.expire(key, self.__redis_conf['blacklist_ttl'])
        BlackRed.__release_connection(connection)
        return False