Class: RightSpeed::ConnectionCloser
- Inherits:
-
Object
- Object
- RightSpeed::ConnectionCloser
- Defined in:
- lib/right_speed/connection_closer.rb
Instance Method Summary collapse
-
#run(workers) ⇒ Object
This class was introduced to serialize closing connections (instead of closing those in each Ractor) to try to avoid SEGV.
- #wait ⇒ Object
Instance Method Details
#run(workers) ⇒ Object
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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/right_speed/connection_closer.rb', line 11 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.}" } end end rescue => e logger.error { "Unexpected error, #{e.class}:#{e.}" } end end |
#wait ⇒ Object
31 32 33 |
# File 'lib/right_speed/connection_closer.rb', line 31 def wait @ractor.take end |