<commit_before>module Reel
  class Server
    include Celluloid::IO
    
    def initialize(host, port, &callback)
      # This is actually an evented Celluloid::IO::TCPServer
      @server = TCPServer.new(host, port)
      @callback = callback
      run!
    end
    
    def finalize
      @server.close
    end
    
    def run
      loop { handle_connection! @server.accept }
    end
    
    def handle_connection(socket)
      connection = Connection.new(socket)
      begin
        @callback[connection]
      ensure
        if connection.attached?
          connection.close rescue nil
        end
      end
    rescue RequestError, EOFError
      # Client disconnected prematurely
      # TODO: log this?
    end<commit_msg>Increase tcp connections backlog to 1024<commit_after>module Reel
  class Server
    include Celluloid::IO

    def initialize(host, port, &callback)
      # This is actually an evented Celluloid::IO::TCPServer
      @server = TCPServer.new(host, port)
      @server.listen(1024)
      @callback = callback
      run!
    end

    def finalize
      @server.close
    end

    def run
      loop { handle_connection! @server.accept }
    end

    def handle_connection(socket)
      connection = Connection.new(socket)
      begin
        @callback[connection]
      ensure
        if connection.attached?
          connection.close rescue nil
        end
      end
    rescue RequestError, EOFError
      # Client disconnected prematurely
      # TODO: log this?
    end
{'fraction_non_alphanumeric': 0.06648936170212766, 'fraction_numerical': 0.005319148936170213, 'mean_word_length': 2.1751054852320677, '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': '4898504', 'n_tokens_mistral': 427, 'n_tokens_neox': 416, 'n_words': 119}