<commit_before>import curses
import curses.textpad
from curses.wrapper import wrapper
from collections import deque
import time

from schema.entity import Entity
from schema.component import *

class Clock(object):
    """
    A simple rate-limiting object that ensures a function will be called at
    most every tick_length seconds.
    """
    def __init__(self, length=None, func=None):
        self.tick_length = length if length > 0 else 1
        self.last_tick_time = 0
        self.funcs = []
        self.ticks = 0

    def register(self, func, *args, **kwargs):
        self.funcs.append((func, args, kwargs))

    def tick(self):
        now = time.time()
        should_tick = now - self.last_tick_time > self.tick_length
        if self.funcs and should_tick:
            self.ticks += 1
            self.last_tick_time = now
            for func, args, kwargs in self.funcs:<commit_msg>Allow zero-tick-length clocks.<commit_after>import curses
import curses.textpad
from curses.wrapper import wrapper
from collections import deque
import time

from schema.entity import Entity
from schema.component import *

class Clock(object):
    """
    A simple rate-limiting object that ensures a function will be called at
    most every tick_length seconds.
    """
    def __init__(self, length=1, func=None):
        self.tick_length = length
        self.last_tick_time = 0
        self.funcs = []
        self.ticks = 0

    def register(self, func, *args, **kwargs):
        self.funcs.append((func, args, kwargs))

    def tick(self):
        now = time.time()
        should_tick = now - self.last_tick_time > self.tick_length
        if self.funcs and should_tick:
            self.ticks += 1
            self.last_tick_time = now
            for func, args, kwargs in self.funcs:
{'fraction_non_alphanumeric': 0.08690807799442897, 'fraction_numerical': 0.005013927576601671, 'mean_word_length': 2.5776892430278884, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5959794', 'n_tokens_mistral': 532, 'n_tokens_neox': 518, 'n_words': 166}