<commit_before>module Dogpile
  
  class Daemon
    
    DEFAULT_WAIT    = Dogpile::CONFIG['default_worker_wait']
    MAX_WAIT        = Dogpile::CONFIG['max_worker_wait']
    WAIT_MULTIPLIER = Dogpile::CONFIG['worker_wait_multiplier']
    
    def initialize
      @wait_time = DEFAULT_WAIT
      @worker = Dogpile::Worker.new
    end
    
    def run
      loop do
        @worker.fetch_work_unit
        if @worker.has_work?
          @worker.run
          @wait_time = DEFAULT_WAIT
        else
          @wait_time = [@wait_time * WAIT_MULTIPLIER, MAX_WAIT].min
          sleep @wait_time
        end
      end
    end
    
  end
  
end<commit_msg>adding a brief sleep to the dogpile daemon so as to enable interruptions, even if it's busy working<commit_after>module Dogpile
  
  class Daemon
    
    DEFAULT_WAIT    = Dogpile::CONFIG['default_worker_wait']
    MAX_WAIT        = Dogpile::CONFIG['max_worker_wait']
    WAIT_MULTIPLIER = Dogpile::CONFIG['worker_wait_multiplier']
    
    def initialize
      @wait_time = DEFAULT_WAIT
      @worker = Dogpile::Worker.new
    end
    
    def run
      loop do
        @worker.fetch_work_unit
        if @worker.has_work?
          @worker.run
          @wait_time = DEFAULT_WAIT
          sleep 0.01 # So as to listen for incoming signals.
        else
          @wait_time = [@wait_time * WAIT_MULTIPLIER, MAX_WAIT].min
          sleep @wait_time
        end
      end
    end
    
  end
  
end
{'fraction_non_alphanumeric': 0.0709855272226051, 'fraction_numerical': 0.002067539627842867, 'mean_word_length': 2.0893617021276594, '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': '7518673', 'n_tokens_mistral': 473, 'n_tokens_neox': 451, 'n_words': 103}