Calculate the current average wait time for each station and prune old wait time calculations.
@param ttl_seconds Time-to-live for wait time calculations, results older than this will be deleted.
@return
@throws VoltAbortException
197070
public VoltTable[] run(short station, long ttl_seconds) throws VoltAbortException {
        voltQueueSQL(getLastDeparts, station);

        // For each station, calculate the wait time between departures
        final StationStats stats = getStationStats(station, voltExecuteSQL());
        voltQueueSQL(updateWaitTime,
                        stats.station,
                        stats.lastDepartTime,
                        stats.totalTime,
                        stats.totalEntries);
        // Prune old data
        voltQueueSQL(deleteOldData, -ttl_seconds);

        return voltExecuteSQL(true);
    }
150764
def get(self):
        
        if self.ttl[self.idx] <= 0:
            self.buffers[self.idx] = self.inqueue.get(timeout=300.0)
            self.ttl[self.idx] = self.cur_max_ttl
            if self.cur_max_ttl < self.max_ttl:
                self.cur_max_ttl += 1
        buf = self.buffers[self.idx]
        self.ttl[self.idx] -= 1
        released = self.ttl[self.idx] <= 0
        if released:
            self.buffers[self.idx] = None
        self.idx = (self.idx + 1) % len(self.buffers)
        return buf, released
402801
public boolean await(long waitDuration, TimeUnit timeUnit) throws InterruptedException {
    return sync.tryAcquireSharedNanos(0, timeUnit.toNanos(waitDuration));
  }
199579
private function getExpiration($ttl) : int
    {
        if ($ttl === null) {
            return PHP_INT_MAX;
        }

        if (is_int($ttl)) {
            return time() + $ttl;
        }

        return (new DateTime())->add($ttl)->getTimestamp();
    }
546019
async function calculateTtl (ttl = 0, relative = true) {
  if (ttl === 0) return 0
  if (ttl < 0) throw new Error('ttl must be greater than 0')

  if (relative) {
    const { height } = await this.api.getCurrentKeyBlock()
    return +(height) + ttl
  }
  return ttl
}
216497
def elapsed_time_s(self):
        
        if self._start_time:
            return (datetime.datetime.now() - self._start_time).total_seconds()
        else:
            return 0
450631
private List<StationStats> getStationStats(List<Short> stations, VoltTable[] lastDepartResult) {
        final List<StationStats> stationStats = new ArrayList<>(stations.size());
        for (int i = 0; i < stations.size(); i++) {
            final short station = stations.get(i);
            TimestampType lastDepartTime;
            if (lastDepartResult[i].advanceRow()) {
                lastDepartTime = lastDepartResult[i].getTimestampAsTimestamp("last_depart");
            } else {
                lastDepartTime = new TimestampType(0);
            }
            voltQueueSQL(getTrainDeparts, station, lastDepartTime);
            final VoltTable departResult = voltExecuteSQL()[0];

            while (departResult.advanceRow()) {
                final TimestampType departTime = departResult.getTimestampAsTimestamp("time");
                voltQueueSQL(getWaitTimeForTrain, departTime, station, lastDepartTime, departTime);
                lastDepartTime = departTime;
            }

            long totalWaitTime = 0;
            long totalEntries = 0;
            if (departResult.getRowCount() > 0) {
                final VoltTable[] waitTimeResult = voltExecuteSQL();
                for (VoltTable res : waitTimeResult) {
                    if (res.advanceRow()) {
                        final long entries = res.getLong("entries");
                        final long waitTime = res.getLong("wait_sum");
                        // Don't record empty train
                        if (entries > 0) {
                            totalEntries += entries;
                            totalWaitTime += waitTime;
                        }
                    }
                }
            }

            stationStats.add(new StationStats(station, lastDepartTime, totalWaitTime, totalEntries));
        }
        return stationStats;
    }
725210
private double popup(double seconds) {
        // wait for up to XX seconds for the error message
        double end = System.currentTimeMillis() + (seconds * 1000);
        WebDriverWait wait = new WebDriverWait(app.getDriver(), (long) seconds, DEFAULT_POLLING_INTERVAL);
        wait.until(ExpectedConditions.alertIsPresent());
        return Math.min((seconds * 1000) - (end - System.currentTimeMillis()), seconds * 1000) / 1000;
    }
575024
private int calculateWaitCyclesFromWaitTime() {

        String serverWaitTime = System.getProperty(BootstrapConstants.SERVER_START_WAIT_TIME);

        if ((serverWaitTime == null) || serverWaitTime.trim().equals("")) {
            return BootstrapConstants.MAX_POLL_ATTEMPTS;
        }

        int waitTime = 0;
        try {
            waitTime = Integer.parseInt(System.getProperty(BootstrapConstants.SERVER_START_WAIT_TIME));

            if (waitTime < 1) {
                return 1;
            }
        } catch (Throwable t) {

            return BootstrapConstants.MAX_POLL_ATTEMPTS;
        }
        int waitCycles = (int) (TimeUnit.MILLISECONDS.convert(waitTime, TimeUnit.SECONDS) / BootstrapConstants.POLL_INTERVAL_MS);

        return waitCycles;
    }
167624
def tdb_minus_tt(jd_tdb):
    
    t = (jd_tdb - T0) / 36525.0

    # USNO Circular 179, eq. 2.6.
    return (0.001657 * sin ( 628.3076 * t + 6.2401)
          + 0.000022 * sin ( 575.3385 * t + 4.2970)
          + 0.000014 * sin (1256.6152 * t + 6.1969)
          + 0.000005 * sin ( 606.9777 * t + 4.0212)
          + 0.000005 * sin (  52.9691 * t + 0.4444)
          + 0.000002 * sin (  21.3299 * t + 5.5431)
          + 0.000010 * t * sin ( 628.3076 * t + 4.2490))
112460
def setTraceTimeToLive(self, trace_id, ttl_seconds):
    
    self.send_setTraceTimeToLive(trace_id, ttl_seconds)
    self.recv_setTraceTimeToLive()
713425
def _wait_time(self, shard_state, secs, now=datetime.datetime.now):
    
    assert shard_state.slice_start_time is not None
    delta = now() - shard_state.slice_start_time
    duration = datetime.timedelta(seconds=secs)
    if delta < duration:
      return util.total_seconds(duration - delta)
    else:
      return 0
611171
def ttl(self, steps, relative_time=None):
    '''
    
    '''
    if steps:
      if relative_time:
        rtime = self.to_bucket(relative_time)
        ntime = self.to_bucket(time.time())
        # The relative time is beyond our TTL cutoff
        if (ntime - rtime) > steps:
          return 0
        # The relative time is in "recent" past or future
        else:
          return (steps + rtime - ntime) * self._step
      return steps * self._step

    return None
941571
AtomicLong getCurrent(int pollerIndex) {
    rollCount(pollerIndex, clock.now());
    return data[2 * pollerIndex + CURRENT];
  }
400092
public long
getTTL() throws IOException {
	String next = _getIdentifier("a TTL value");
	try {
		return TTL.parseTTL(next);
	}
	catch (NumberFormatException e) {
		throw exception("expected a TTL value");
	}
}
1043813
public void wait(double seconds) {
        String action = "Wait " + seconds + SECONDS;
        String expected = WAITED + seconds + SECONDS;
        try {
            Thread.sleep((long) (seconds * 1000));
        } catch (InterruptedException e) {
            log.warn(e);
            reporter.fail(action, expected, "Failed to wait " + seconds + SECONDS + ". " + e.getMessage());
            Thread.currentThread().interrupt();
            return;
        }
        reporter.pass(action, expected, WAITED + seconds + SECONDS);
    }
613080
public function setTtl($ttl)
    {
        if ($this->isOpened()) {
            throw new Exception('Session is already opened, ttl cannot be set');
        }

        if ($ttl < 1) {
            throw new Exception('$ttl must be greather than 0');
        }

        $this->ttl = (int)$ttl;
    }