class Parallel::Worker
Attributes
Public Class Methods
Source
# File lib/parallel.rb, line 48 def initialize(read, write, pid) @read, @write, @pid = read, write, pid end
Public Instance Methods
Source
# File lib/parallel.rb, line 59 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 52 def stop close_pipes wait # if it goes zombie, rather wait here to be able to debug end
Source
# File lib/parallel.rb, line 64 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 ExceptionWrapper === result result end
Private Instance Methods
Source
# File lib/parallel.rb, line 82 def wait Process.wait(pid) rescue Interrupt # process died end