BackgrounDRb: Re-call do_work or non blocking methods?

S

Stephan Dale

Hi.

I've been trying to use BackgrounDRb for a couple of weeks now and have
been experiencing some very odd behaviour, (largely due to Rails'
behaviour in the face of threads but also) due to my misunderstanding
BackgrounDRb.

Given the following example (from the rdoc), creating a new worker calls
the do_work method, which is ran in a new process and hence doesn't
block. Later calling the other_method on the worker DOES block.

key = MiddleMan.new_worker:)class => :example_worker) <-- This doesn't
block.
worker = MiddleMan.worker(key)
worker.other_method <-- This blocks.
worker.delete

1. Is that the correct behaviour? I had assumed that other_method
wouldn't block.
2. Is there any way of re-calling the do_work method, or any other
methods, in a way which doesn't block? If you just call do_work, it
blocks.

Thanks.

Steph

P.S. The only way I have found to do this is via the scheduler, like so.

MiddleMan.schedule_worker(
:class => :example_worker,
:job_key => :schedule_test,
:worker_method => :arg_method,
:worker_method_args => { :arg => "whatever", :another_arg =>
"whatever else" },
:trigger_args => {
:start => Time.now + 5.seconds
}
)

The problem is that it creates a new worker, which defeats the point of
what I'm trying to do.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,104
Latest member
LesliVqm09
Top