<commit_before>import sys
import time
import timer2

from celery.datastructures import TokenBucket
from celery.events import EventReceiver
from celery.events.state import State
from celery.messaging import establish_connection
from celery.utils import instantiate
from celery.utils.dispatch import Signal
from celery.utils.timeutils import rate


class Polaroid(object):
    shutter_signal = Signal(providing_args=("state", ))
    cleanup_signal = Signal()

    _tref = None

    def __init__(self, state, freq=1.0, maxrate=None, cleanup_freq=60.0,
            verbose=False):
        self.state = state
        self.freq = freq
        self.cleanup_freq = cleanup_freq
        self.verbose = verbose
        self.maxrate = maxrate and TokenBucket(rate(maxrate))

    def install(self):
        self._tref = timer2.apply_interval(self.freq * 1000.0,
                                           self.capture)
        self._ctref = timer2.apply_interval(self.cleanup_freq * 1000.0,
                                            self.cleanup)

    def on_shutter(self, state):
        pass

    def on_cleanup(self):
        pass

    def cleanup(self):
        self.debug("Cleanup: Running...")<commit_msg>Set snapshot cleanup frequency to 1 hour by default.<commit_after>import sys
import time
import timer2

from celery.datastructures import TokenBucket
from celery.events import EventReceiver
from celery.events.state import State
from celery.messaging import establish_connection
from celery.utils import instantiate
from celery.utils.dispatch import Signal
from celery.utils.timeutils import rate


class Polaroid(object):
    shutter_signal = Signal(providing_args=("state", ))
    cleanup_signal = Signal()

    _tref = None

    def __init__(self, state, freq=1.0, maxrate=None,
            cleanup_freq=3600.0, verbose=False):
        self.state = state
        self.freq = freq
        self.cleanup_freq = cleanup_freq
        self.verbose = verbose
        self.maxrate = maxrate and TokenBucket(rate(maxrate))

    def install(self):
        self._tref = timer2.apply_interval(self.freq * 1000.0,
                                           self.capture)
        self._ctref = timer2.apply_interval(self.cleanup_freq * 1000.0,
                                            self.cleanup)

    def on_shutter(self, state):
        pass

    def on_cleanup(self):
        pass

    def cleanup(self):
        self.debug("Cleanup: Running...")
{'fraction_non_alphanumeric': 0.08145722472370037, 'fraction_numerical': 0.015963978714695046, 'mean_word_length': 2.4914285714285715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '207219', 'n_tokens_mistral': 714, 'n_tokens_neox': 646, 'n_words': 171}