Sha256: d321feb999aabaaae7598fd2acc3efe7521868de5d308cdf1e60b7ee80a2d5d6
Contents?: true
Size: 931 Bytes
Versions: 1
Compression:
Stored size: 931 Bytes
Contents
# frozen_string_literal: true require_relative "logger" module RightSpeed class ConnectionCloser # This class was introduced to serialize closing connections # (instead of closing those in each Ractor) to try to avoid SEGV. # But SEGV is still happening, so this class may not be valueable. def run(workers) @ractor = Ractor.new(workers) do |workers| logger = RightSpeed.logger while workers.size > 0 r, conn = Ractor.select(*workers, move: true) if conn == :closing workers.delete(r) next end begin conn.close rescue => e logger.debug { "Error while closing a connection #{conn}, #{e.class}:#{e.message}" } end end rescue => e logger.error { "Unexpected error, #{e.class}:#{e.message}" } end end def wait @ractor.take end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
right_speed-0.2.0 | lib/right_speed/connection_closer.rb |