[Backgroundrb-devel] MiddleMan.worker blocks?

Marc Evans Marc at SoftwareHackery.Com
Wed Mar 7 13:22:14 EST 2007

Hello -

I am observing that calls to MiddleMan.worker return only after the worker 
has completed its work. This puzzles me, and I presume that I am doing 
something wrong. Can anyone make suggestions?

Snippets from my code are:

class ReportController < SecurityController
     def create_xml_report(report,start_time)
       constraints = get_constraints(report,start_time,false)
       args = { :constraints => constraints,
                :start_time => start_time,
                :report_params => report
       # For reasons unknown, the following seems to block!
       session[:xml_report_job] =
         MiddleMan.new_worker(:class => :xml_report_worker, :args => args)

   def get_progress
           worker = MiddleMan.worker(session[job])

class XmlReportWorker < BackgrounDRb::Worker::RailsBase
   include DRbUndumped
   def do_work(args)
     @progress = 0
     @report_start_time = args[:start_time]
     @report_params = args[:report_params]
     constraints = args[:constraints]
     dtd_only = args[:dtd_only]
     io = Tmpfile.new('csv_report','/var/tmp')
     @path = io.path
     xml = Builder::XmlMarkup.new(:indent => 2, :target => io)
     (dtd_only.nil? or !dtd_only) ? data(xml,constraints) : dtd(xml)
     @progress = 100

Within the run_worker, the data method is where the bulk of the time is 
spent, though to my understanding, what I do in that method should not be 
able to impact the blocking state of the queries to get_progress. The data 
method does ALOT of postgresql interaction to extract the data needed to 
build the report, all of which is read-only.

Does anyone have suggestions for what may be causing the blocking 
situation, and/or how to figure out and fix that issue?

Thanks in advance - Marc

More information about the Backgroundrb-devel mailing list