<commit_before>#!/usr/bin/env ruby

require 'rubygems'
require 'yaml'
require 'transmission-client'
require 'lib/transmission-connect'

CONFIG = "config/transmission.yml"
result = []

while true
  begin
    EventMachine.run do
      transmission = Configuration.new(YAML.load_file(CONFIG))
      transmission.each do |client|
        EM.add_periodic_timer(client.interval) do
          client.report
        end
      end
      EM.add_periodic_timer(2) do
        transmission.each do |client|
          client.session_stats
        end
      end
      EventMachine::start_server "127.0.0.1", 2456, TransmissionServer do |server|
        server.connectors = transmission
      end
    end
  rescue Exception => e
    puts "Error: #{e.message}"
  end
end<commit_msg>Handle system signals and correct exit from app<commit_after>#!/usr/bin/env ruby

require 'rubygems'
require 'yaml'
require 'transmission-client'
require 'lib/transmission-connect'

CONFIG = "config/transmission.yml"
@exit = false

trap("INT") do
  EventMachine::stop_event_loop
  @exit = true
end

trap("TERM") do
  EventMachine::stop_event_loop
  @exit = true
end

while !@exit
  begin
    EventMachine.run do
      transmission = Configuration.new(YAML.load_file(CONFIG))
      transmission.each do |client|
        EM.add_periodic_timer(client.interval) do
          client.report
        end
      end
      EM.add_periodic_timer(2) do
        transmission.each do |client|
          client.session_stats
        end
      end
      EventMachine::start_server "127.0.0.1", 2456, TransmissionServer do |server|
        server.connectors = transmission
      end
    end
  rescue Exception => e
    puts "Error: #{e.message}"
  end
end
{'fraction_non_alphanumeric': 0.09453904873752202, 'fraction_numerical': 0.012918379330593071, 'mean_word_length': 2.8552036199095023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7205553', 'n_tokens_mistral': 540, 'n_tokens_neox': 525, 'n_words': 127}