backgrounDRb: problem with saving files within the worker

Hi,
in my rails app I’m using BackgrounDRb and I have problems with saving
the generated files into the temp directory within the do_work method of
my
worker. Despite the fact that in log the are written paths to all files,
it actually saves only the half of the files (first file, then 21st file
and then from 46 to the last one which is 98).

Here is the invocation of the worker in the controller:

MiddleMan.new_worker :class => :page_capturer_worker, :args => {
:page_address => “http://127.0.0.1:3001/cd_creator/product/”,
:product_ids => @products }, :job_key => ‘page_capturer’

Any ideas?

Here is the code of the worker:

class PageCapturerWorker < BackgrounDRb::Rails
require ‘open-uri’
require ‘tempfile’

def do_work(args)
lines = []
@temppathes = []

@logger.debug "Object #{self.object_id} : #{self.class}."

page_addr = args[:page_address]
products = args[:product_ids]


products.each do |p|
  file = open(page_addr.to_s + "" + p.to_s){ |f| f.each_line {|line|

lines << line}}
tmpfile = Tempfile.new(“product_” + p.to_s)
tmpfile.puts lines.join(’’)
tmpfile.close
@logger.debug “File saved in " + tmpfile.path + " for product” +
p.to_s + “.”
@temppathes << tmpfile.path
lines = []
end

MiddleMan.cache_as('pathes', 300, @temppathes)

end

end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs