<commit_before>
require 'thread'
require 'timers'

class RestCore::Timer
  @mutex = Mutex.new

  def self.group
    @group ||= @mutex.synchronize{ @group || group_new }
  end

  def self.group_new
    g = Timers::Group.new
    g.every(1){}
    @thread = Thread.new do
      begin
        g.wait
      rescue => e
        warn "timeout exception: #{e}"
      end while g.count > 1
      @group = nil
    end
    g
  end

  attr_accessor :timeout, :error
  def initialize timeout, error, &block
    self.timeout = timeout
    self.error   = error
    self.block   = block
    start
  end

  def on_timeout &block
    self.block = block
  end

  def cancel
    timer.cancel
    self.block = nil
  end
<commit_msg>update warning messages for timer<commit_after>
require 'thread'
require 'timers'

class RestCore::Timer
  @mutex = Mutex.new

  def self.group
    @group ||= @mutex.synchronize{ @group || group_new }
  end

  def self.group_new
    g = Timers::Group.new
    g.every(1){}
    @thread = Thread.new do
      begin
        g.wait
      rescue => e
        warn "RestCore::Timer: ERROR: #{e}\n  from #{e.backtrace.inspect}"
      end while g.count > 1
      @group = nil
    end
    g
  end

  attr_accessor :timeout, :error
  def initialize timeout, error, &block
    self.timeout = timeout
    self.error   = error
    self.block   = block
    start
  end

  def on_timeout &block
    self.block = block
  end

  def cancel
    timer.cancel
    self.block = nil
  end

{'fraction_non_alphanumeric': 0.09823848238482384, 'fraction_numerical': 0.0027100271002710027, 'mean_word_length': 2.2178649237472765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2094072', 'n_tokens_mistral': 503, 'n_tokens_neox': 492, 'n_words': 144}