<commit_before># See https://github.com/sappho/sappho-heatmiser-proxy/wiki for project documentation.
# This software is licensed under the GNU Affero General Public License, version 3.
# See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
# Copyright 2012 <NAME>.

module Sappho
  module Heatmiser
    module Proxy

      require 'sappho-heatmiser-proxy/heatmiser'
      require 'sappho-heatmiser-proxy/heatmiser_client'
      require 'sappho-heatmiser-proxy/client_register'
      require 'sappho-heatmiser-proxy/trace_log'
      require 'thread'
      require 'socket'

      class CommandLine

        def CommandLine.process
          Thread.abort_on_exception = true
          Thread.new do
            clients = ClientRegister.instance
            port = Integer SystemConfiguration.instance.config['heatmiser.port']
            log = TraceLog.instance
            log.info "opening proxy server port #{port}"
            TCPServer.open port do | server |
              log.info "proxy server port #{port} is now open"
              loop do
                if clients.maxAlreadyConnected?
                  sleep 1
                else
                  log.info "listening for new clients on proxy server port #{port}"
                  Thread.new server.accept { |client| HeatmiserClient.new(client).communicate }
                end
              end
            end
          end
          Thread.new{Heatmiser.new.monitor}.join
        end

      end

    end
  end
end
<commit_msg>Fix threading error.<commit_after># See https://github.com/sappho/sappho-heatmiser-proxy/wiki for project documentation.
# This software is licensed under the GNU Affero General Public License, version 3.
# See http://www.gnu.org/licenses/agpl.html for full details of the license terms.
# Copyright 2012 <NAME>.

module Sappho
  module Heatmiser
    module Proxy

      require 'sappho-heatmiser-proxy/heatmiser'
      require 'sappho-heatmiser-proxy/heatmiser_client'
      require 'sappho-heatmiser-proxy/client_register'
      require 'sappho-heatmiser-proxy/trace_log'
      require 'thread'
      require 'socket'

      class CommandLine

        def CommandLine.process
          Thread.abort_on_exception = true
          Thread.new do
            clients = ClientRegister.instance
            port = Integer SystemConfiguration.instance.config['heatmiser.port']
            log = TraceLog.instance
            log.info "opening proxy server port #{port}"
            TCPServer.open port do | server |
              log.info "proxy server port #{port} is now open"
              loop do
                if clients.maxAlreadyConnected?
                  sleep 1
                else
                  log.info "listening for new clients on proxy server port #{port}"
                  Thread.new server.accept do |client|
                    HeatmiserClient.new(client).communicate
                  end
                end
              end
            end
          end
          Thread.new{Heatmiser.new.monitor}.join
        end

      end

    end
  end
end

{'fraction_non_alphanumeric': 0.07078215901745313, 'fraction_numerical': 0.003878474466709761, 'mean_word_length': 1.8925233644859814, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '4414049', 'n_tokens_mistral': 860, 'n_tokens_neox': 805, 'n_words': 230}