<commit_before>require 'socket'
require 'celluloid'
Thread.abort_on_exception = true

class KeyServer
  include Celluloid

  def initialize port, callback
    @port     = port
    @callback = callback
  end

  # screen_server.listen
  def listen
    Thread.new do
      Socket.tcp_server_loop @port, &register
    end
  end

  def register
    ->(socket, client_info) {
      socket.sync = true
      Thread.new do
        loop {
          @callback[ socket.getc ]<commit_msg>read more bytes from the key socket<commit_after>require 'socket'
require 'celluloid'
Thread.abort_on_exception = true

class KeyServer
  READSIZE = 4096
  include Celluloid

  def initialize port, callback
    @port     = port
    @callback = callback
  end

  # screen_server.listen
  def listen
    Thread.new do
      Socket.tcp_server_loop @port, &register
    end
  end

  def register
    ->(socket, client_info) {
      socket.sync = true
      Thread.new do
        loop {
          @callback[ socket.readpartial( READSIZE ) ]
{'fraction_non_alphanumeric': 0.0722057368941642, 'fraction_numerical': 0.003956478733926805, 'mean_word_length': 2.6142857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2849557', 'n_tokens_mistral': 315, 'n_tokens_neox': 305, 'n_words': 89}