Sha256: 6f11c722dbb136a689c1996c9aa766c9d8c274c2b4ef7bc08ac233d4ffe52dff
Contents?: true
Size: 904 Bytes
Versions: 17
Compression:
Stored size: 904 Bytes
Contents
require 'fileutils' module DeadlySerious module Engine module OpenIo def run(*args, readers: [], writers:[]) opened_readers = readers.map { |reader| wrap_io(reader) } opened_writers = writers.map { |writer| wrap_io(writer) } super(*args, readers: opened_readers, writers: opened_writers) ensure if opened_writers opened_writers.each { |writer| close_io(writer) } end if opened_readers opened_readers.each { |reader| close_io(reader) } end end private def close_io(io) return unless io return if io.closed? io.close rescue => e # Intentionally eat the error # because it's being used inside # an "ensure" block puts e.inspect end def wrap_io(pipe_name) Channel.new(pipe_name).io end end end end
Version data entries
17 entries across 17 versions & 1 rubygems