<commit_before>import socket
import threading
from time import sleep


class Heart(threading.Thread):
    interval = 60

    def __init__(self, eventer, hostname=None, interval=None):
        super(Heart, self).__init__()
        self.eventer = eventer
        self.interval = interval or self.interval
        self.hostname = hostname or socket.gethostname()
        self._shutdown = threading.Event()
        self._stopped = threading.Event()
        self.setDaemon(True)

    def run(self):
        hostname = self.hostname
        interval = self.interval
        send = self.eventer.send

        send("worker-online", hostname=hostname)

        while 1:
            if self._shutdown.isSet():
                break
            send("worker-heartbeat", hostname=hostname)
            sleep(interval)
        self._stopped.set()

        send("worker-offline", hostname=hostname)

    def stop(self):
        """Gracefully shutdown the thread."""
        self.on_stop()
        self._shutdown.set()
        self._stopped.wait() # block until this thread is done<commit_msg>Removed reference to on_stop in Heart<commit_after>import socket
import threading
from time import sleep


class Heart(threading.Thread):
    interval = 60

    def __init__(self, eventer, hostname=None, interval=None):
        super(Heart, self).__init__()
        self.eventer = eventer
        self.interval = interval or self.interval
        self.hostname = hostname or socket.gethostname()
        self._shutdown = threading.Event()
        self._stopped = threading.Event()
        self.setDaemon(True)

    def run(self):
        hostname = self.hostname
        interval = self.interval
        send = self.eventer.send

        send("worker-online", hostname=hostname)

        while 1:
            if self._shutdown.isSet():
                break
            send("worker-heartbeat", hostname=hostname)
            sleep(interval)
        self._stopped.set()

        send("worker-offline", hostname=hostname)

    def stop(self):
        """Gracefully shutdown the thread."""
        self._shutdown.set()
        self._stopped.wait() # block until this thread is done
{'fraction_non_alphanumeric': 0.10060268891979601, 'fraction_numerical': 0.0027816411682892906, 'mean_word_length': 2.3098159509202456, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2329414', 'n_tokens_mistral': 609, 'n_tokens_neox': 596, 'n_words': 143}