<commit_before>require 'json'
require 'rest_client'
require 'thread'
require 'timeout'

module Exoteric
  class Counter
    attr_reader :url, :options

    def self.<<(counter)
      send :include, counter
      counters << counter.id
    end

    def self.counters
      @counters ||= []
    end
    
    def initialize(options = {})
      @url, @options = options[:url], options
      raise ArgumentError, "Site url not specified" if @url.to_s.empty?
    end

    def count(*counters)
      if counters.size == 0 || counters.first == :all
        counters = self.class.counters
      end
      
      res = {}
      sem = Mutex.new
      threads = []

      counters.each do |name|
        threads << Thread.new do 
          sem.synchronize { res[name] = send("#{name}_count") }
        end
      end

      Timeout.timeout(10) do
        threads.each(&:join)
      end<commit_msg>sychro in other way around, nothing changes though...<commit_after>require 'json'
require 'rest_client'
require 'thread'
require 'timeout'

module Exoteric
  class Counter
    attr_reader :url, :options

    def self.<<(counter)
      send :include, counter
      counters << counter.id
    end

    def self.counters
      @counters ||= []
    end
    
    def initialize(options = {})
      @url, @options = options[:url], options
      raise ArgumentError, "Site url not specified" if @url.to_s.empty?
    end

    def count(*counters)
      if counters.size == 0 || counters.first == :all
        counters = self.class.counters
      end
      
      res = {}
      sem = Mutex.new
      threads = []

      counters.each do |name|
        threads << Thread.new do 
          c = send("#{name}_count") 
          sem.synchronize { res[name] = c }
        end
      end

      Timeout.timeout(10) do
        threads.each(&:join)
      end
{'fraction_non_alphanumeric': 0.11342465753424658, 'fraction_numerical': 0.0032876712328767125, 'mean_word_length': 2.089678510998308, 'pattern_counts': {'":': 0, '<': 15, '<?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': '2723562', 'n_tokens_mistral': 572, 'n_tokens_neox': 548, 'n_words': 150}