I'm having problems passing objects to backgroundrb workers. The worker methods
(including create) don't seem to get called by the MiddleMan when the :data
parameter is a user-defined object. I'm creating workers from a rails 1.2
controller, using BDRB 1.0.4, packet 0.1.14 and chronic 0.2.3.
The worker is trivial - the create method logs the parameters passed in. I'm
creating workers using the following:
MiddleMan.new_worker(:worker => :test_worker,
:worker_key => "test key",
:data => TestClass.new())
When :data is a string, the create method is called, and the log is made.
However, when attempting to pass in a test class (which is completely trivial),
there is no log from the worker's create method. The test class lives at
app/models/test_class.rb.
A log in backgroundrb_debug_11006.log gives an exception inside the packet gem:
/usr/local/lib/ruby/gems/1.8/gems/packet-0.1.14/bin/packet_worker_runner:24:in
`load': undefined class/module TestClass (ArgumentError)
from
/usr/local/lib/ruby/gems/1.8/gems/packet-0.1.14/bin/packet_worker_runner:24:in
`initialize'
from
/usr/local/lib/ruby/gems/1.8/gems/packet-0.1.14/bin/packet_worker_runner:47:in
`new'
from
/usr/local/lib/ruby/gems/1.8/gems/packet-0.1.14/bin/packet_worker_runner:47
from /usr/local/bin/packet_worker_runner:16:in `load'
from /usr/local/bin/packet_worker_runner:16
The path $: contains all the relevant directories to find the classes - I've
also tried explicitly requiring test_class from the worker and the controller,
which makes no difference.
Does anyone have any thoughts on how I can fix this?
test_class and test_worker source is below
[test_class.rb]
class TestClass
end
[test_worker.rb]
class TestWorker < BackgrounDRb::MetaWorker
set_worker_name :test_worker
set_no_auto_load(true)
def create(args = nil)
logger.info("#{Time.now}: Creating test worker with args: #{args}")
end
end
_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel