<commit_before># This module handles the generic bits of the poller gem and
# is intended to be mixed into any concrete Poller implementations
# The generic parts include the periodic checking of a Probe and
# raising a RuntimeError in case the timeout period has been exceeded

module Poller
  module Poller

    def initialize(probe, timeout_s, period_s)
      @probe = probe
      @timeout_s = timeout_s
      @period_s = period_s
    end

    def check
      # comment on testability
      @timeout ||= Timeout.new(@timeout_s)

      while !@probe.satisfied?
        raise RuntimeError, 'Timeout period has been exceeded' if @timeout.occured?
        Kernel.sleep @period_s
      end
    end

  end
end<commit_msg>add comment on testability<commit_after># This module handles the generic bits of the poller gem and
# is intended to be mixed into any concrete Poller implementations
# The generic parts include the periodic checking of a Probe and
# raising a RuntimeError in case the timeout period has been exceeded

module Poller
  module Poller

    def initialize(probe, timeout_s, period_s)
      @probe = probe
      @timeout_s = timeout_s
      @period_s = period_s
    end

    def check
      # This following line allows us to inject a timeout object from within our tests
      @timeout ||= Timeout.new(@timeout_s)

      while !@probe.satisfied?
        raise RuntimeError, 'Timeout period has been exceeded' if @timeout.occured?
        Kernel.sleep @period_s
      end
    end

  end
end
{'fraction_non_alphanumeric': 0.0504983388704319, 'fraction_numerical': 0.0, 'mean_word_length': 3.0813008130081303, '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': '2089421', 'n_tokens_mistral': 417, 'n_tokens_neox': 398, 'n_words': 179}