<commit_before>require 'eventmachine'

class Redch::Loop
  def initialize(period)
    raise ArgumentError.new("the time period must be especified") if period.nil?
    @period = period # seconds
  end

  def start(&block)
    EventMachine.run do

      EventMachine.add_periodic_timer(@period) do
        begin
          yield
        rescue StandardError => e
          EventMachine.stop
          raise e
        end
      end

    end
  end

  def stop(&block)
    return if !EventMachine::reactor_running?
<commit_msg>Tiny refactor<commit_after>require 'eventmachine'

class Redch::Loop
  def initialize(period)
    raise ArgumentError.new("the time period must be especified") if period.nil?
    @period = period # seconds
  end

  def start(&block)
    EventMachine.run do

      EventMachine.add_periodic_timer(@period) do
        begin
          yield
        rescue StandardError => e
          EventMachine.stop
          raise e
        end
      end

    end
  end

  def stop(&block)
    return unless EventMachine::reactor_running?

{'fraction_non_alphanumeric': 0.06985645933014355, 'fraction_numerical': 0.0, 'mean_word_length': 2.4407894736842106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7012006', 'n_tokens_mistral': 299, 'n_tokens_neox': 290, 'n_words': 85}