# BackgrounDRb: Re-call do\_work or non blocking methods?

**URL:** <https://www.ruby-forum.com/t/backgroundrb-re-call-do-work-or-non-blocking-methods/112056>\
**Category:** Ruby\
**Created:** [August 14, 2007, 7:10pm UTC](https://www.ruby-forum.com/t/backgroundrb-re-call-do-work-or-non-blocking-methods/112056 "2007-08-14T19:10:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stephan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8baadc/32.png) [@stephan](https://www.ruby-forum.com/u/stephan)\
**Post date:** [August 14, 2007, 7:10pm UTC](https://www.ruby-forum.com/t/backgroundrb-re-call-do-work-or-non-blocking-methods/112056/1 "2007-08-14T19:10:54Z")

</div>

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.
