318: def initialize(host, port, num_processors=20, timeout=120)
319: @socket = TCPServer.new(host, port)
320:
321: @classifier = URIClassifier.new
322: @req_queue = Queue.new
323: @host = host
324: @port = port
325: @num_processors = num_processors
326: @timeout = timeout
327:
328: @num_processors.times {|i| Thread.new do
329: while client = @req_queue.deq
330: begin
331: Timeout.timeout(@timeout) do
332: process_client(client)
333: end
334: rescue Timeout::Error
335: STDERR.puts "WARNING: Request took longer than #@timeout second timeout"
336: end
337: end
338: end
339: }
340: end