<commit_before>#!/usr/bin/env python

from threading import Thread as _Thread
from threading import enumerate as threads

try:
    from multiprocessing import Pipe as _Pipe
    from multiprocessing import Value as _Value
    from multiprocessing import Process as _Process

    from multiprocessing import cpu_count as cpus
    from multiprocessing import active_children as processes
except ImportError:
    from processing import Pipe as _Pipe
    from processing import Value as _Value
    from processing import Process as _Process

    from processing import cpuCount as cpus
    from processing import activeChildren as processes

from circuits.core import Component as _Component

POLL_INTERVAL = 0.00001

class Thread(_Component):

    def __init__(self, *args, **kwargs):
        super(Thread, self).__init__(*args, **kwargs)

        self._running = False
        self._thread = _Thread(target=self.run)

    def start(self):
        self._running = True
        self._thread.start()

    def run(self):
        pass

    def stop(self):
        self._running = False

    def join(self):
        return self._thread.join()

    def isAlive(self):
        return self.running and self.thread.isAlive()

class Process(_Component):

    def __init__(self, *args, **kwargs):
        super(Process, self).__init__(*args, **kwargs)

        self.running = _Value("b", False)
        self.process = _Process(target=self._run, args=(self.run, self.running,))
        self.parent, self.child = _Pipe()

    def _run(self, fn, running):
        thread = _Thread(target=fn)
        thread.start()

        try:<commit_msg>workers: Deprecated isAlive function in favour of alive property.<commit_after>#!/usr/bin/env python

from threading import Thread as _Thread
from threading import enumerate as threads

try:
    from multiprocessing import Pipe as _Pipe
    from multiprocessing import Value as _Value
    from multiprocessing import Process as _Process

    from multiprocessing import cpu_count as cpus
    from multiprocessing import active_children as processes
except ImportError:
    from processing import Pipe as _Pipe
    from processing import Value as _Value
    from processing import Process as _Process

    from processing import cpuCount as cpus
    from processing import activeChildren as processes

from circuits.core import Component as _Component

POLL_INTERVAL = 0.00001

class Thread(_Component):

    def __init__(self, *args, **kwargs):
        super(Thread, self).__init__(*args, **kwargs)

        self._running = False
        self._thread = _Thread(target=self.run)

    def start(self):
        self._running = True
        self._thread.start()

    def run(self):
        pass

    def stop(self):
        self._running = False

    def join(self):
        return self._thread.join()

    @property
    def alive(self):
        return self._running and self._thread.isAlive()

class Process(_Component):

    def __init__(self, *args, **kwargs):
        super(Process, self).__init__(*args, **kwargs)

        self.running = _Value("b", False)
        self.process = _Process(target=self._run, args=(self.run, self.running,))
        self.parent, self.child = _Pipe()

    def _run(self, fn, running):
        thread = _Thread(target=fn)
        thread.start()

        try:
{'fraction_non_alphanumeric': 0.08247734138972809, 'fraction_numerical': 0.0036253776435045317, 'mean_word_length': 3.0526315789473686, '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': '7348339', 'n_tokens_mistral': 953, 'n_tokens_neox': 910, 'n_words': 302}