Method: PatronusFati::Connection#start_write_thread

Defined in:
lib/patronus_fati/connection.rb

#start_write_threadvoid (protected)



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/patronus_fati/connection.rb', line 73

def start_write_thread
  self.write_thread = Thread.new do
    begin
      count = 0
      while (msg = write_queue.pop)
        socket.write("!%i %s\r\n" % [count, msg])
        count += 1
      end
    rescue => e
      PatronusFati.logger.error(format('Error in write thread: %s %s', e.class.to_s, e.message))
      e.backtrace.each do |l|
        PatronusFati.logger.error(l)
      end
    ensure
      socket.close if socket && !socket.closed?
    end
  end
end