bin/parserver in biodiversity-1.0.2 vs bin/parserver in biodiversity-1.0.3

- old
+ new

@@ -78,20 +78,21 @@ puts "Running parser service on port #{OPTIONS[:port]}, output type is '#{OPTIONS[:output]}'" parser = ScientificNameParser.new server = TCPServer.open(OPTIONS[:port]) # Socket to listen on a port loop do # Servers run forever client = server.accept # Wait for a client to connect - while true - begin - a = client.readline - a.force_encoding("utf-8") if a && RUBY_VERSION_INT >= 19 - if ['end','exit','q', '.'].include? a.strip - client.close - break - end - client.puts get_output(a, parser) - rescue EOFError + puts 'opening client' + count = 0 + while a = client.readline rescue nil + count += 1 + puts "parsed %s'th name" % count if count % 1000 == 0 + a.force_encoding("utf-8") if a && RUBY_VERSION_INT >= 19 + if ['end','exit','q', '.'].include? a.strip client.close break end + out = get_output(a, parser).strip + client.write(out + "\n") rescue break end + puts 'closing client' + client.close end