Return current heart rate for in-progress session.
553100
def current_heart_rate(self):
        """"""
        try:
            rates = self.intervals[0]['timeseries']['heartRate']
            num_rates = len(rates)

            if num_rates == 0:
                return None

            rate = rates[num_rates-1][1]
        except KeyError:
            rate = None
        return rate
86667
private int determineHeartbeatInterval(Map properties)
    {
        // How often should we heartbeat?
        int heartbeatInterval = JFapChannelConstants.DEFAULT_HEARTBEAT_INTERVAL;
        try
        {
            heartbeatInterval = Integer.parseInt(RuntimeInfo.getProperty(JFapChannelConstants.RUNTIMEINFO_KEY_HEARTBEAT_INTERVAL, "" + heartbeatInterval));
        } catch (NumberFormatException nfe)
        {
            // No FFDC code needed
        }

        if (properties != null)
        {
            String intervalStr = (String) properties.get(JFapChannelConstants.CHANNEL_CONFIG_HEARTBEAT_INTERVAL_PROPERTY);
            if (intervalStr != null)
            {
                try
                {
                    heartbeatInterval = Integer.parseInt(intervalStr);
                } catch (NumberFormatException nfe)
                {
                    // No FFDC code needed
                }
            }
        }
        return heartbeatInterval;
    }
736242
def tick(self):
    """"""
    count = self._uncounted.getAndSet(0)
    instantRate = float(count) / self.interval

    if self._initialized:
      self.rate += (self.alpha * (instantRate - self.rate))
    else:
      self.rate = instantRate
      self._initialized = True
59686
def get_runtime(self):
        """"""
        if self.start is None: return None

        if self.end is None:
            delta = datetime.datetime.now() - self.start
        else:
            delta = self.end - self.start

        return MyTimedelta.as_timedelta(delta)
1221636
def Heartbeat(self):
    """"""
    service_key = _GetServiceKey()
    try:
      winreg.SetValueEx(service_key, "Nanny.heartbeat", 0, winreg.REG_DWORD,
                        int(time.time()))
    except OSError as e:
      logging.debug("Failed to heartbeat nanny at %s: %s", service_key, e)
784380
def run_checked (self):
        """"""
        self.start_time = time.time()
        self.setName("Status")
        # the first status should be after a second
        wait_seconds = 1
        first_wait = True
        while not self.stopped(wait_seconds):
            self.log_status()
            if first_wait:
                wait_seconds = self.wait_seconds
                first_wait = False
425409
public int getNextHeartbeatInterval() {
    // get the no of task trackers
    int clusterSize = getClusterStatus().getTaskTrackers();
    int heartbeatInterval =  Math.max(
                                (int)(1000 * HEARTBEATS_SCALING_FACTOR *
                                      Math.ceil((double)clusterSize /
                                                NUM_HEARTBEATS_IN_SECOND)),
                                HEARTBEAT_INTERVAL_MIN) ;
    return heartbeatInterval;
  }
1196788
def heartbeat(request):
    
    all_checks = checks.registry.registry.get_checks(
        include_deployment_checks=not settings.DEBUG,
    )

    details = {}
    statuses = {}
    level = 0

    for check in all_checks:
        detail = heartbeat_check_detail(check)
        statuses[check.__name__] = detail['status']
        level = max(level, detail['level'])
        if detail['level'] > 0:
            details[check.__name__] = detail

    if level < checks.messages.WARNING:
        status_code = 200
        heartbeat_passed.send(sender=heartbeat, level=level)
    else:
        status_code = 500
        heartbeat_failed.send(sender=heartbeat, level=level)

    payload = {
        'status': level_to_text(level),
        'checks': statuses,
        'details': details,
    }
    return JsonResponse(payload, status=status_code)
166502
def last_session_date(self):
        """"""
        try:
            date = self.intervals[1]['ts']
        except KeyError:
            return None
        date_f = datetime.strptime(date, '%Y-%m-%dT%H:%M:%S.%fZ')
        now = time.time()
        offset = datetime.fromtimestamp(now) - datetime.utcfromtimestamp(now)
        return date_f + offset
1088289
def get_current_live_chat(self):
        
        now = datetime.now()
        chat = self.upcoming_live_chat()
        if chat and chat.is_in_progress():
            return chat
        return None
49250
private static function checkHeartBeat($session_object=null) {
        global $CFG;

        if ( session_id() == "" ) return;  // This should not start the session

        if ( isset($CFG->sessionlifetime) ) {
            if (self::wrapped_session_get($session_object,'LAST_ACTIVITY') ) {
                $heartbeat = $CFG->sessionlifetime/4;
                $ellapsed = time() - self::wrapped_session_get($session_object,'LAST_ACTIVITY');
                if ( $ellapsed > $heartbeat ) {
                    self::wrapped_session_put($session_object,'LAST_ACTIVITY', time());
                    // TODO: Remove this after verification
                    $filename = isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '';
                    error_log("Heartbeat ".session_id().' '.$ellapsed.' '.$filename);
                }
            } else {
                self::wrapped_session_put($session_object,'LAST_ACTIVITY', time());
            }
        }
    }
159514
def current_resp_rate(self):
        """"""
        try:
            rates = self.intervals[0]['timeseries']['respiratoryRate']
            num_rates = len(rates)

            if num_rates == 0:
                return None

            rate = rates[num_rates-1][1]
        except KeyError:
            rate = None
        return rate
439415
def get_current_program_progress(program):
    '''
    
    '''
    now = datetime.datetime.now()
    program_duration = get_program_duration(program)
    if not program_duration:
        return
    progress = now - program.get('start_time')
    return progress.seconds * 100 / program_duration
89581
def track_progress(**context):
    """"""
    model = context["model"]
    train_X = context["train_X"]
    dev_X = context["dev_X"]
    dev_y = context["dev_y"]
    n_train = len(train_X)
    trainer = context["trainer"]

    def each_epoch():
        global epoch_train_acc, epoch
        with model.use_params(trainer.optimizer.averages):
            avg_acc = model.evaluate_logloss(dev_X, dev_y)
        stats = (avg_acc, float(epoch_train_acc) / n_train, trainer.dropout)
        print("%.3f dev acc, %.3f train acc, %.4f drop" % stats)
        epoch_train_acc = 0.0
        epoch += 1

    return each_epoch
621468
def heartbeat(self):
        """"""
        while self._manager.is_active and not self._stop_event.is_set():
            self._manager.heartbeat()
            _LOGGER.debug("Sent heartbeat.")
            self._stop_event.wait(timeout=self._period)

        _LOGGER.info("%s exiting.", _HEARTBEAT_WORKER_NAME)
1296922
def is_alive(self):
        
        response = self.get_monitoring_heartbeat()
        if response.status_code == 200 and response.content == 'alive':
            return True

        return False
1124568
def is_running(self) -> bool:
        """"""
        return (
            self._has_started and
            self.is_alive() or
            self.completed_at is None or
            (datetime.utcnow() - self.completed_at).total_seconds() < 0.5
        )