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
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---