Create the timer, and schedule a task that will let us know when the file
is too old to continue. If the age limit is 0 or negative, we treat it as
"no limit".
431780
private Timer createTimer() {
        Timer fileTimer = new Timer();

        // if the age limit is 0 or negative, treat it as "no limit".
        if (ageLimit >= 0) {
            fileTimer.schedule(new CloseFileTimerTask(), ageLimit);
        }

        return fileTimer;
    }
611912
public boolean start(Runnable task, long timeout)
  {
    long expire;

    if (timeout < 0 || timeout > MAX_EXPIRE)
      expire = MAX_EXPIRE;
    else
      expire = CurrentTime.getCurrentTimeActual() + timeout;

    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    boolean isPriority = false;
    boolean isQueue = false;
    boolean isWake = true;

    return scheduleImpl(task, loader, expire, isPriority, isQueue, isWake);
  }
287718
function _setTimeLimit(options, done) {
        if (options && options.timeLimit && options.pidFile) {
          var timeout = setTimeout(function() {
                var kill = 'kill $(cat ' + options.pidFile + ')';
                if (logLevel === 'trace') logger.warn('process', kill);
                childProcess.exec(kill, function(err, stdout, stderr) {
                    if (err) {
                      if (logLevel === 'trace') logger.error('process', 'timeout', err);
                    }
                    if (stderr) {
                      if (logLevel === 'trace') logger.warn('process', 'timeout', stderr);
                    }
                    if (stdout) {
                      if (logLevel === 'trace') logger.info('process', 'timeout', stdout);
                    }
                    options.returnNow = 'Sorry, that file took too long to process';
                  });
                }, options.timeLimit);
          done(timeout);
        }
        else {
          done(false);
        }
      }
948923
private synchronized void startTimer() {
    if (timer == null) {
      timer = new Timer("Timer thread for monitoring " + getContextName(), 
                        true);
      TimerTask task = new TimerTask() {
          public void run() {
            try {
              timerEvent();
            }
            catch (IOException ioe) {
              ioe.printStackTrace();
            }
          }
        };
      long millis = period * 1000;
      timer.scheduleAtFixedRate(task, millis, millis);
    }
  }
1210996
def setup(self):
        """"""
        if self.mlogfilter.is_stdin:
            # assume this year (we have no other info)
            now = datetime.now()
            self.startDateTime = datetime(now.year, 1, 1, tzinfo=tzutc())
            self.endDateTime = datetime(MAXYEAR, 12, 31, tzinfo=tzutc())

        else:
            logfiles = self.mlogfilter.args['logfile']
            self.startDateTime = min([lf.start +
                                      timedelta(hours=self
                                                .mlogfilter
                                                .args['timezone'][i])
                                      for i, lf in enumerate(logfiles)])
            self.endDateTime = max([lf.end +
                                    timedelta(hours=self
                                              .mlogfilter.args['timezone'][i])
                                    for i, lf in enumerate(logfiles)])

        # now parse for further changes to from and to datetimes
        dtbound = DateTimeBoundaries(self.startDateTime, self.endDateTime)
        self.fromDateTime, self.toDateTime = dtbound(self.mlogfilter
                                                     .args['from'] or None,
                                                     self.mlogfilter
                                                     .args['to'] or None)

        # define start_limit for mlogfilter's fast_forward method
        self.start_limit = self.fromDateTime

        # for single logfile, get file seek position of `to` datetime
        if (len(self.mlogfilter.args['logfile']) == 1 and not
                self.mlogfilter.is_stdin):

            if self.mlogfilter.args['to'] != "end":
                # fast forward, get seek value, then reset file
                logfile = self.mlogfilter.args['logfile'][0]
                logfile.fast_forward(self.toDateTime)
                self.seek_to = logfile.filehandle.tell()
                logfile.filehandle.seek(0)
            else:
                self.seek_to = -1
        else:
            self.seek_to = False
149607
function (options, callback) {

			fs.stat(options.file_path, function (err, stats) {

				if (err) {
					callback(err);
				}
				else {
					var local_date = new Date(stats.mtime).getTime();
					var server_date = new Date(options.server_date).getTime();

					if (options.compare_date === 'newer') {
						callback(null, local_date > server_date);
					}
					else {
						callback(null, local_date < server_date);
					}
				}
			});
		}
320809
def set(self, value):
        """"""
        self.deadline = self.timer() + self.duration
        self.value = value
1264136
final void begin() {
    if (this.properties.isDateRollEnforced()) {
      final Thread thread = new Thread(this,
          "Log4J Time-based File-roll Enforcer");
      thread.setDaemon(true);
      thread.start();
      this.threadRef = thread;
    }
  }
439855
private void enforceTimeLimits()
    {
        for (T query : queries.values()) {
            if (query.isDone()) {
                continue;
            }
            Duration queryMaxRunTime = getQueryMaxRunTime(query.getSession());
            Duration queryMaxExecutionTime = getQueryMaxExecutionTime(query.getSession());
            Optional<DateTime> executionStartTime = query.getExecutionStartTime();
            DateTime createTime = query.getCreateTime();
            if (executionStartTime.isPresent() && executionStartTime.get().plus(queryMaxExecutionTime.toMillis()).isBeforeNow()) {
                query.fail(new PrestoException(EXCEEDED_TIME_LIMIT, "Query exceeded the maximum execution time limit of " + queryMaxExecutionTime));
            }
            if (createTime.plus(queryMaxRunTime.toMillis()).isBeforeNow()) {
                query.fail(new PrestoException(EXCEEDED_TIME_LIMIT, "Query exceeded maximum time limit of " + queryMaxRunTime));
            }
        }
    }
711047
def roll_required?
      return false if ::File.exist?(@fn_copy) and (Time.now - ::File.mtime(@fn_copy)) < 180

      # check if max size has been exceeded
      s = @size ? ::File.size(@fn) > @size : false

      # check if max age has been exceeded
      a = sufficiently_aged?

      return (s || a)
    end
94878
def enforce_time_limit(self, site):
        '''
        
        '''
        if (site.time_limit and site.time_limit > 0
                and site.elapsed() > site.time_limit):
            self.logger.debug(
                    "site FINISHED_TIME_LIMIT! time_limit=%s "
                    "elapsed=%s %s", site.time_limit, site.elapsed(), site)
            raise brozzler.ReachedTimeLimit
1101252
def age(*paths):
	''''''
	if not paths:
		return 0

	for path in paths:
		if not os.path.exists(path):
			return time.time()

	return min([(time.time() - os.path.getmtime(path)) for path in paths])
1277817
def start(self):
        """"""
        assert not self._timer, '%r is already started; to restart it, cancel it first' % self
        loop = evergreen.current.loop
        current = evergreen.current.task
        if self.seconds is None or self.seconds < 0:
            # "fake" timeout (never expires)
            self._timer = None
        elif self.exception is None or isinstance(self.exception, bool):
            # timeout that raises self
            self._timer = loop.call_later(self.seconds, self._timer_cb, current.throw, self)
        else:
            # regular timeout with user-provided exception
            self._timer = loop.call_later(self.seconds, self._timer_cb, current.throw, self.exception)
1141190
def set(self, f):
        """"""
        self.stop()
        self._create_timer(f)
        self.start()
175074
boolean extendLeaseTime(String caller, long threadId, long leaseTime) {
        if (!isLockedBy(caller, threadId)) {
            return false;
        }
        this.blockReads = true;
        if (expirationTime < Long.MAX_VALUE) {
            setExpirationTime(expirationTime - Clock.currentTimeMillis() + leaseTime);
        }
        return true;
    }
171712
def set_file_limits(n):
    '''
    

    '''

    try:
        resource.setrlimit(resource.RLIMIT_NOFILE, (n, n))
        return True
    except ValueError:
        return False
928140
def set_expire(self, new_expire, only_read=False):
        
        if not isinstance(new_expire, int) or new_expire < 0:
            self.logger.warning('Parameter new_expire %s must be positive number' % new_expire)
            return
        self.expire = new_expire