Check if all slaves have become available
2209
protected function allSlavesReady()
    {
        if ($this->status === self::STATE_STARTING || $this->status === self::STATE_EMERGENCY) {
            $readySlaves = $this->slaves->getByStatus(Slave::READY);
            $busySlaves = $this->slaves->getByStatus(Slave::BUSY);
            return count($readySlaves) + count($busySlaves) === $this->slaveCount;
        }

        return false;
    }
661614
function () {
        if (job.pull_requests < worker_count) {
            return false;
        }
        for (var i = 0; i < worker_count; i++) {
            if (!job.worker_complete[i]) {
                return false;
            }
        }
        return true;
    }
71838
function checkIfNoWorkersAndExit() {
            if (!currentWorkersCount) {
                log('Cluster graceful shutdown: done.');
                if (shutdownTimer) clearTimeout(shutdownTimer);
                exitFunction();
            } else {
                log('Cluster graceful shutdown: wait ' + currentWorkersCount + ' worker' + (currentWorkersCount > 1 ? 's' : '') + '.');
            }
        }
188533
def checkIfAvailable(self, dateTime=timezone.now()):
        '''
        
        '''
        return (
            self.startTime >= dateTime + timedelta(days=getConstant('privateLessons__closeBookingDays')) and
            self.startTime <= dateTime + timedelta(days=getConstant('privateLessons__openBookingDays')) and not
            self.eventRegistration and (
                self.status == self.SlotStatus.available or (
                    self.status == self.SlotStatus.tentative and
                    getattr(getattr(self.temporaryEventRegistration,'registration',None),'expirationDate',timezone.now()) <= timezone.now()
                )
            )
        )
931953
def locked(self):
        
        if len(self.failed) == 0:
            return False
        for fail in self.failed:
            for job in self.active_jobs:
                if fail.alias in job.depends_on:
                    return True
253970
def is_available(self) -> bool:
        """"""
        status_response = self.get_state(
            'api/host/daemonCheck.json'
        )

        if not status_response:
            return False

        return status_response.get('result') == 1
285480
def check_status(self):
        """"""
        # Recompute the status of the tasks
        # Ignore OK and LOCKED tasks.
        for task in self:
            if task.status in (task.S_OK, task.S_LOCKED): continue
            task.check_status()

        # Take into account possible dependencies. Use a list instead of generators
        for task in self:
            if task.status == task.S_LOCKED: continue
            if task.status < task.S_SUB and all(status == task.S_OK for status in task.deps_status):
                task.set_status(task.S_READY, "Status set to Ready")
443215
def is_ready(self):
        """"""
        if not self.provisioning_state:
            raise exception.ServiceException("The object doesn't contain "
                                             "`provisioningState`.")
        elif self.provisioning_state == constant.FAILED:
            raise exception.ServiceException(
                "Failed to complete the required operation.")
        elif self.provisioning_state == constant.SUCCEEDED:
            LOG.debug("The model %s: %s was successfully updated "
                      "(or created).",
                      self.__class__.__name__, self.resource_id)
            return True

        return False
462623
public function occupy()
    {
        if ($this->status !== self::READY) {
            throw new \LogicException('Cannot occupy a slave that is not in ready state');
        }

        $this->status = self::BUSY;
    }
745533
def status(self):
        
        if 'sandbox_type' in self.engine.data:
            if self.engine.sandbox_type == 'none':
                return False
            return True
        return False
940000
def check_running_job_count():
    """"""
    try:
        job_list = current_k8s_batchv1_api_client.\
            list_job_for_all_namespaces()
        if len(job_list.items) > K8S_MAXIMUM_CONCURRENT_JOBS:
            return False
    except ApiException as e:
        log.error('Something went wrong while getting running job list.')
        log.error(e)
        return False
    return True
1161578
def filter_slaves(selfie, slaves):
        
        return [(s['ip'], s['port']) for s in slaves
                if not s['is_odown'] and
                not s['is_sdown'] and
                s['master-link-status'] == 'ok']
1285777
def gather_candidates(self):
        
        async def slave_task(addr):
            r_manager = await self.env.connect(addr)
            return await r_manager.get_candidates()

        if self._single_env:
            self._candidates = self.env.candidates
        else:
            mgrs = self.get_managers()
            tasks = create_tasks(slave_task, mgrs)
            self._candidates = run(tasks)
2337
function isAvailable(state, feed_id, ignore_id) {
  for(var peer_id in state.peers) {
    if(peer_id != ignore_id) {
      var peer = state.peers[peer_id]
      //BLOCK: check wether id has blocked this peer
      if((peer.clock && peer.clock[feed_id] || 0) > (state.clock[feed_id] || 0) && isShared(state, feed_id, peer_id)) {
        return true
      }
    }
  }
}
1026672
async def gather(self):
        
        if self.__state == 'new':
            self.__setState('gathering')
            await self._connection.gather_candidates()
            self.__setState('completed')
1229037
function () {
                    //Check if any input was added dynamically
                    if (job.input.length > 0) {
                        job.is_complete = false;
                        return false;
                    }

                    //Wait for workers or instances that are still working
                    return worker_count > 0 ? areWorkersComplete() : job.instances <= 0;
                }
1229206
def _check_existence_by_collection(self, container, item_name):
        '''
        '''

        coll = container.get_collection()
        for item in coll:
            if item.name == item_name:
                return True
        return False