示例#1
0
def _build(callables):
    schedule = _Schedule()
    now = None
    immediates = []
    # Reverse order is used since these are later popped off (and to
    # ensure the popping order is first -> last we need to append them
    # in the opposite ordering last -> first).
    for i, cb in misc.reverse_enumerate(callables):
        if cb._periodic_run_immediately:
            immediates.append(i)
        else:
            if now is None:
                now = _now()
            schedule.push_next(cb, i, now=now)
    return immediates, schedule
示例#2
0
def _build(callables):
    schedule = _Schedule()
    now = None
    immediates = []
    # Reverse order is used since these are later popped off (and to
    # ensure the popping order is first -> last we need to append them
    # in the opposite ordering last -> first).
    for i, cb in misc.reverse_enumerate(callables):
        if cb._periodic_run_immediately:
            immediates.append(i)
        else:
            if now is None:
                now = _now()
            schedule.push_next(cb, i, now=now)
    return immediates, schedule
 def stop(self):
     """Stops & joins all associated threads (that have been started)."""
     count = 0
     with self._lock:
         it = misc.reverse_enumerate(self._threads)
         for i, (builder, thread, started) in it:
             if not thread or not started:
                 continue
             builder.before_join(thread)
             thread.join()
             count += 1
             try:
                 builder.after_join(thread)
             finally:
                 # Just incase the 'after_join' callback blows up make sure
                 # we always set/reset these...
                 self._threads[i][1] = thread = None
                 self._threads[i][2] = started = False
     return count
示例#4
0
 def stop(self):
     """Stops & joins all associated threads (that have been started)."""
     count = 0
     with self._lock:
         it = misc.reverse_enumerate(self._threads)
         for i, (builder, thread, started) in it:
             if not thread or not started:
                 continue
             builder.before_join(thread)
             thread.join()
             count += 1
             try:
                 builder.after_join(thread)
             finally:
                 # Just incase the 'after_join' callback blows up make sure
                 # we always set/reset these...
                 self._threads[i][1] = thread = None
                 self._threads[i][2] = started = False
     return count
示例#5
0
 def test_sample_equivalence(self):
     expected = list(reversed(list(enumerate(self.sample))))
     actual = list(misc.reverse_enumerate(self.sample))
     self.assertEqual(expected, actual)
示例#6
0
 def test_sample_equivalence(self):
     expected = list(reversed(list(enumerate(self.sample))))
     actual = list(misc.reverse_enumerate(self.sample))
     self.assertEqual(expected, actual)