class Parallel::Worker
Attributes
Public Class Methods
Source
# File lib/parallel.rb, line 55 def initialize(read, write, pid) @read = read @write = write @pid = pid end
Public Instance Methods
Source
# File lib/parallel.rb, line 68 def close_pipes read.close unless read.closed? write.close unless write.closed? end
might be passed to started_processes and simultaneously closed by another thread when running in isolation mode, so we have to check if it is closed before closing
Source
# File lib/parallel.rb, line 61 def stop close_pipes wait # if it goes zombie, rather wait here to be able to debug end
Source
# File lib/parallel.rb, line 73 def work(data) begin Marshal.dump(data, write) rescue Errno::EPIPE raise DeadWorker end result = begin Marshal.load(read) rescue EOFError raise DeadWorker end raise result.exception if result.is_a?(ExceptionWrapper) result end
Private Instance Methods
Source
# File lib/parallel.rb, line 91 def wait Process.wait(pid) rescue Interrupt # process died end