Class: Sqew::Worker
Instance Method Summary collapse
Instance Method Details
#fork_job(job) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/sqew/worker.rb', line 5 def fork_job(job) rd, wr = IO.pipe pid = fork do srand rd.close job.perform_forked(wr) # catch special exception and regular/internalXS ones # add logging to regular (internal) end Thread.new do begin Process.wait(pid) wr.close Marshal.load(rd.read) ensure rd.close end end end |