[Backgroundrb-devel] Feedback on RC2

Andy Tyra andy.tyra at gmail.com
Thu Dec 6 22:15:06 EST 2007


Sure, here is the worker code in its entirety.  For a little background,
this is using the test framework to call a controller function which
executes and renders a report.  It's done this way because the previous
version of backgroundrb did not support accessing and calling controllers.
(If this has changed, that would be awesome, but I'm guessing it has not.)
That's what the extra "FakeTest" class is for.

require 'active_support'
require 'action_controller'
require 'action_controller/test_process'
require 'action_view'

class ExpireAndRefreshWorker < BackgrounDRb::MetaWorker
  set_worker_name :expire_and_refresh_worker
  def create(args = nil)
    # this method is called, when worker is loaded for the first time
  end

  def execute_report(report_name)
        myReport = Report.new(report_name)
        begin
                File.delete(File.join(RAILS_ROOT, 'public','reports',
myReport.const_name + '.html'))
        rescue
                #do nothing
        end
        renderController = FakeTest.new
        renderController.render_report(myReport)
        return "I am done."
  end

  def process_request(p_data)
    user_input = p_data[:data]
    result = self.send(user_input[:worker_method],user_input[:data])
    send_response(p_data,result)
  end
end

class FakeTest

        include ActionController::TestProcess

        def initialize
                require_dependency 'application' unless
defined?(ApplicationController)
                @controller = ReportsController.new
                @request = ActionController::TestRequest.new
                @response = ActionController::TestResponse.new
        end

        def render_report(myReport)
                get :run, {:id => myReport.const_name}
                @response
        end
end


On Dec 6, 2007 6:24 PM, hemant kumar <gethemant at gmail.com> wrote:

>
> On Thu, 2007-12-06 at 17:31 -0800, Andy Tyra wrote:
> > Another issue to report.
> >
> > When running the aforementioned worker manually, it runs and seems to
> > work, but the worker process crashes at the end, leaving this stack
> > trace:
> >
> >
> rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/nbio.rb:55:in
> `dump': can't dump anonymous class #<Class:0xb6a4ccc8> (TypeError)
> >         from
> >
> rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/nbio.rb:55:in
> `dump_object'
> >         from
> > rails-root/vendor/plugins/backgroundrb/framework/worker.rb:32:in
> > `send_data'
> >         from
> > rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:79:in
> > `send_response'
> >         from rails-root/lib/workers/expire_and_refresh_worker.rb:36:in
> > `process_request'
> >         from
> > rails-root/vendor/plugins/backgroundrb/server/meta_worker.rb:48:in
> > `receive_data'
> >         from
> > rails-root/vendor/plugins/backgroundrb/framework/worker.rb:54:in
> > `receive_internal_data'
> >         from
> >
> rails-root/config/../vendor/plugins/backgroundrb/lib/../framework/bin_parser.rb:30:in
> `extract'
> >         from
> > rails-root/vendor/plugins/backgroundrb/framework/worker.rb:52:in
> > `receive_internal_data'
> >          ... 11 levels...
> >         from
> > rails-root/vendor/plugins/backgroundrb/framework/packet_master.rb:19:in
> `run'
> >         from
> > rails-root/vendor/plugins/backgroundrb/server/master_worker.rb:114:in
> > `initialize'
> >         from script/backgroundrb:73:in `new'
> >         from script/backgroundrb:73
>
> Can I have a look at your worker script? If not possible..you can send
> me personally and I will have a look.
>
> I do think, its because of return issue.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20071206/a06bf598/attachment.html 


More information about the Backgroundrb-devel mailing list