[Backgroundrb-devel] MiddleMan.worker blocks?

Marc Evans Marc at SoftwareHackery.Com
Wed Mar 7 14:08:26 EST 2007


I see the I place a comment in my posting in the wrong place. See in 
context below:

On Wed, 7 Mar 2007, Marc Evans wrote:

> 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)

The above line is NOT the problem line...

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

The above line IS the line that I am finding blocks when called, until the 
worker is complete with its work.

>   end
>   ...
> end
>
> 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)
>     xml.instruct!
>     (dtd_only.nil? or !dtd_only) ? data(xml,constraints) : dtd(xml)
>     io.close
>     @progress = 100
>   end
>   ...
> end
>
> 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
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>


More information about the Backgroundrb-devel mailing list