Starts executing the method at the specified interval.

    Args:
      interval_s: The amount of time between executions of the method.
    Returns:
      False if the interval was already running.
169535
def start(self, interval_s):
    
    if self.running:
      return False

    self.stopped.clear()

    def _execute():
      # Always execute immediately once
      if not self.method() and self.stop_if_false:
        return
      while not self.stopped.wait(interval_s):
        if not self.method() and self.stop_if_false:
          return

    self.thread = threading.Thread(target=_execute)
    self.thread.daemon = True
    self.thread.start()
    return True
520625
def interval_timer(interval, func, *args, **kwargs):
    '''
    '''
    stopped = Event()

    def loop():
        while not stopped.wait(interval):  # the first call is after interval
            func(*args, **kwargs)

    Thread(name='IntervalTimerThread', target=loop).start()
    return stopped.set
966393
function backgroundRefreshInit(){
    if(!backgroundRefreshEnabled){
      backgroundRefreshEnabled = true;
      if(self.backgroundRefreshIntervalCheck){
        if(self.backgroundRefreshInterval > self.backgroundRefreshMinTtl){
          throw new Error('BACKGROUND_REFRESH_INTERVAL_EXCEPTION: backgroundRefreshInterval cannot be greater than backgroundRefreshMinTtl.');
        }
      }
      interval = setInterval(backgroundRefresh, self.backgroundRefreshInterval);
    }
  }
410579
def tointerval(s):
    
    if isinstance(s, basestring):
        m = coord_re.search(s)
        if m.group('strand'):
            return pybedtools.create_interval_from_list([
                m.group('chrom'),
                m.group('start'),
                m.group('stop'),
                '.',
                '0',
                m.group('strand')])
        else:
            return pybedtools.create_interval_from_list([
                m.group('chrom'),
                m.group('start'),
                m.group('stop'),
            ])
    return s
1358796
def RepeatTimer(interval, function, iterations=0, *args, **kwargs):
  """"""

  def __repeat_timer(interval, function, iterations, args, kwargs):
    """Inner function, run in background thread."""
    count = 0
    while iterations <= 0 or count < iterations:
      sleep(interval)
      function(*args, **kwargs)
      count += 1

  return start_new_thread(__repeat_timer, (interval, function, iterations, args, kwargs))
1296061
private int compareStarts(Interval<T> other){
		if (start == null && other.start == null)
			return 0;
		if (start == null)
			return -1;
		if (other.start == null)
			return 1;
		int compare = start.compareTo(other.start);
		if (compare != 0)
			return compare;
		if (isStartInclusive ^ other.isStartInclusive)
			return isStartInclusive ? -1 : 1;
		return 0;
	}
654889
def add_interval(self, start, end, data=None):
        '''
        
        '''
        # Ignore intervals of 0 or negative length
        if (end - start) <= 0:
            return
        if self.single_interval is None:
            # This is an empty tree and we are adding the first interval. Just record it in a field.
            self.single_interval = (start, end, data)
        elif self.single_interval == 0:
            # This is a usual tree, use standard addition method
            self._add_interval(start, end, data)
        else:
            # This is a tree with a single interval. Convert to a usual tree.
            self._add_interval(*self.single_interval)
            self.single_interval = 0
            self._add_interval(start, end, data)
435003
def _interval_split(interval, only=None, context=None, event_re=re.compile("[A-Z][0-9]+")):
    
    def split_event(event):
        "Helper to parse events."
        kind, val = event[:1], event[1:]
        try:
            return kind, float(val)
        except (TypeError, ValueError):
            return None, 0

    if hasattr(interval, "fetch"):
        interval = interval.fetch("custom_activations")
    ##import sys; print >>sys.stderr, "!!!!!isplit", interval, event_re.findall(interval)

    return list(reversed([split_event(i) for i in event_re.findall(interval) if not only or i.startswith(only)]))
985339
def pt_within(self, pt, subject):
        """"""
        try:
            if pt >= int(subject[0]) and pt <= int(subject[1]):
                return True
        except ValueError:
            raise ValueError('Interval start and stop has to be integers. %s' % str(subject))

        return False
1241123
def start_datetime(self) -> Optional[datetime.datetime]:
        
        if not self.intervals:
            return None
        return self.intervals[0].start
1367548
def start(self, seconds=300):
        
        if self.state is TimerState.stopped:
            self.compare = time.time() + abs(seconds)
            self.state = TimerState.running
        elif self.state is TimerState.running:
            self.increase(seconds)
350174
def _startTimer(self, interval):
        
        if not self.__timer:
            self.__timer = QtCore.QTimer(self)
            self.__timer.setSingleShot(self.__singleShot)
            self.__timer.setInterval(interval)
            self.__timer.timeout.connect(self.timeout)
            self.__timer.destroyed.connect(self._clearTimer)

            # ensure to stop this timer when the app quits
            QtCore.QCoreApplication.instance().aboutToQuit.connect(self.__timer.stop, QtCore.Qt.QueuedConnection)
        
        self.__timer.start(interval)
301923
def setInterval(self, msecs):
        
        with QtCore.QWriteLocker(self.__lock):
            self.__interval = msecs
            self._intervalChanged.emit(msecs)
97546
def add_thread(self, func, interval):
        
        t = Thread(func, interval, self.output_dict)
        t.start()
        self._thread_pool.append(t)
684568
def execute(self, time_interval):
        
        logging.info('{} with sink node {} running from {} to {}'.format(
            self.tool.__class__.__name__, self.sink.node_id, time_interval.start, time_interval.end))

        if self.plates:
            if isinstance(self.tool, AggregateTool):
                if len(self.sources) != 1:
                    raise ValueError("Currently only a single source node is valid for an Aggregate Tool")
                if self.alignment_node:
                    raise ValueError("Currently an alignment node cannot be used with an Aggregate Tool")
                
                all_sources = self.sources[0]
                
                # Here we should loop through the plate values of the sink, and get the sources that are appropriate for
                # that given plate value, and pass only those sources to the tool. This is cleaner than making the tool
                # deal with all of the sources
                for pv in self.sink.plate_values:
                    sources = [all_sources.streams[s] for s in all_sources.streams if all([v in s for v in pv])]
                    sink = self.sink.streams[pv]
                    self.tool.execute(sources=sources, sink=sink, interval=time_interval, alignment_stream=None)
            elif isinstance(self.tool, SelectorTool):
                if len(self.sources) == 1:
                    sources = self.sources[0].streams.values()
                elif len(self.sources) == 2:
                    selector_node = self.sources[0]
                    if len(selector_node.streams) != 1:
                        raise ValueError("Selector node should only have one stream")
                    sources = [self.sources[0].streams[None], self.sources[1].streams.values()]
                else:
                    raise ValueError("Currently only one or twos source nodes are valid for a Selector Tool")
                if self.alignment_node:
                    raise ValueError("Currently an alignment node cannot be used with a Selector Tool")
                
                diff, counts, is_sub_plate = self.sources[-1].difference(self.sink)
                # TODO: This sub-plate selection is deprecated

                if (counts == [1, 1] and is_sub_plate) or \
                    (len(self.sink.plates)==1 and counts == [1, 0] and is_sub_plate) or \
                    (next(p.is_root for p in self.sources[-1].plates)
                     and len(self.sink.plates) == 1
                     and self.sink.plates[0] in self.sources[-1].plates):
                        # Special case of tools that are performing sub-selection
                        self.tool.execute(sources=sources,
                                          sinks=self.sink.streams.values(),
                                          interval=time_interval)
                else:
                    raise ValueError("Source and sink plates do not match within a Selector Tool")
            else:
                # TODO: This loop over plates is probably not correct:
                # What we probably want is to take the cartesian product of plate values
                if len(self.plates) == 1:
                    plate = self.plates[0]
                    for pv in plate.values:
                        sources = self.get_sources(plate, pv)
                        sink = self.sink.streams[pv]
                        self.tool.execute(sources=sources, sink=sink, interval=time_interval,
                                          alignment_stream=self.get_alignment_stream(None, None))
                else:
                    if len(self.sources) != 1 and not all(s.plates == self.plates for s in self.sources):
                        source_plates = sorted(p.plate_id for s in self.sources for p in s.plates)
                        self_plates = sorted(p.plate_id for p in self.plates)
                        if source_plates == self_plates:
                            # This is the case where the sources are all on separate plates and the sink is the
                            # combination
                            search = [[x[0] for x in p.values] for p in self.plates]
                            _pv = sorted(itertools.product(*search))
                            for pv in _pv:
                                # Here we're selecting the streams that have the partial match of the plate value
                                sources = [source.streams[s] for source in self.sources
                                           for s in source.streams if (s[0] in pv)]
                                try:
                                    sink = self.sink.streams[pv]
                                    self.tool.execute(sources=sources, sink=sink, interval=time_interval,
                                                  alignment_stream=self.get_alignment_stream(None, None))
                                except KeyError as e:
                                    continue

                        else:
                            raise NotImplementedError
                    for pv in Plate.get_overlapping_values(self.plates):
                        sources = [source.streams[s] for source in self.sources for s in source.streams if pv == s]
                        sink = self.sink.streams[pv]
                        self.tool.execute(sources=sources, sink=sink, interval=time_interval,
                                          alignment_stream=self.get_alignment_stream(None, None))
        else:
            if isinstance(self.tool, AggregateTool):
                # raise ValueError("Cannot execute an AggregateTool if no plates are defined for the factor")
                # Here we're trying to aggregate off a plate. This is only allowed for a single non-overlapping plate.
                if len(self.sources) != 1:
                    raise ValueError("Currently only a single source node is valid for an Aggregate Tool")
                if self.alignment_node:
                    raise ValueError("Currently an alignment node cannot be used with an Aggregate Tool")

                sources = self.sources[0].streams.values()
                sink = self.sink.streams[None]
                self.tool.execute(sources=sources, sink=sink, interval=time_interval, alignment_stream=None)

            else:
                # sources = [source.streams[None] for source in self.sources] if self.sources else None
                sources = self.get_global_sources()
                sink = self.sink.streams[None]
                self.tool.execute(sources=sources, sink=sink, interval=time_interval,
                                  alignment_stream=self.get_alignment_stream(None, None))
        return self
273046
def set_interval(self, timer_id, interval):
        
        return lib.ztimerset_set_interval(self._as_parameter_, timer_id, interval)
1268445
public S interval(Long interval) {
        builder.interval(String.valueOf(interval));
        return self;
    }