class Parallel::Worker
Attributes
pid[R]
read[R]
thread[RW]
write[R]
Public Class Methods
new(read, write, pid)
click to toggle source
# File lib/parallel.rb, line 34 def initialize(read, write, pid) @read, @write, @pid = read, write, pid end
Public Instance Methods
close_pipes()
click to toggle source
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
# File lib/parallel.rb, line 45 def close_pipes read.close unless read.closed? write.close unless write.closed? end
stop()
click to toggle source
# File lib/parallel.rb, line 38 def stop close_pipes wait # if it goes zombie, rather wait here to be able to debug end
work(data)
click to toggle source
# File lib/parallel.rb, line 50 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
wait()
click to toggle source
# File lib/parallel.rb, line 68 def wait Process.wait(pid) rescue Interrupt # process died end