[Backgroundrb-devel] Feedback on RC2

hemant gethemant at gmail.com
Fri Dec 7 05:39:10 EST 2007


On Dec 7, 2007 8:45 AM, Andy Tyra <andy.tyra at gmail.com> wrote:
> 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
>
>

Hi Andy,

I am trying to reproduce this. Currently since, we do a require
'environment' all your controllers are available in workers too.
However, the error you are reporting seems to have happen when there
is communication back and forth between workers or master. But i do
not see that case either, since your worker is running in a pretty
stand alone manner.

What i doubt is, either rails or some other lib that rails is using
having a method called "send_response" defined..and thats causing some
conflict or something.
Let me see it further.


More information about the Backgroundrb-devel mailing list