# DRb: execute method but dont wait for it to finish

**URL:** <https://www.ruby-forum.com/t/drb-execute-method-but-dont-wait-for-it-to-finish/187014>\
**Category:** Ruby\
**Created:** [April 15, 2010, 7:39pm UTC](https://www.ruby-forum.com/t/drb-execute-method-but-dont-wait-for-it-to-finish/187014 "2010-04-15T19:39:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![christoforever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@christoforever](https://www.ruby-forum.com/u/christoforever)\
**Post date:** [April 15, 2010, 7:39pm UTC](https://www.ruby-forum.com/t/drb-execute-method-but-dont-wait-for-it-to-finish/187014/1 "2010-04-15T19:39:40Z")

</div>

Basically I want to execute a method on a drb service but not wait for  
it to return … The DRb service is undumped … basically just telling  
it to do something. Is there any easy way to do this?

---

<div class="post-metadata">

**Author:** ![christoforever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@christoforever](https://www.ruby-forum.com/u/christoforever)\
**Post date:** [April 15, 2010, 10:23pm UTC](https://www.ruby-forum.com/t/drb-execute-method-but-dont-wait-for-it-to-finish/187014/2 "2010-04-15T22:23:02Z")

</div>

Christopher Dancy wrote:

> Basically I want to execute a method on a drb service but not wait for  
> it to return … The DRb service is undumped … basically just telling  
> it to do something. Is there any easy way to do this?

Run it in a sub thread you don’t join on?  
-rp

---

<div class="post-metadata">

**Author:** ![christoforever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@christoforever](https://www.ruby-forum.com/u/christoforever)\
**Post date:** [April 16, 2010, 3:33pm UTC](https://www.ruby-forum.com/t/drb-execute-method-but-dont-wait-for-it-to-finish/187014/3 "2010-04-16T15:33:55Z")

</div>

> Run it in a sub thread you don’t join on?  
> -rp

That’s actually what I’m doing now and then killing off the thread after  
a few seconds so as not to waste the precious resources of my 1 single  
ruby process. I was hoping there was a more elegant solution or maybe  
just a “right” way to do it.

---

<div class="post-metadata">

**Author:** ![christoforever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@christoforever](https://www.ruby-forum.com/u/christoforever)\
**Post date:** [April 16, 2010, 4:59pm UTC](https://www.ruby-forum.com/t/drb-execute-method-but-dont-wait-for-it-to-finish/187014/4 "2010-04-16T16:59:58Z")

</div>

DRb is inherently synchronous, so unfortunately not. Depending on your  
problem, you might look at using an asynchronous system such as  
DelayedJob  
or Resque

On Fri, Apr 16, 2010 at 7:34 AM, Christopher Dancy  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![christoforever](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/6de8d8/32.png) [@christoforever](https://www.ruby-forum.com/u/christoforever)\
**Post date:** [April 16, 2010, 6:10pm UTC](https://www.ruby-forum.com/t/drb-execute-method-but-dont-wait-for-it-to-finish/187014/5 "2010-04-16T18:10:19Z")

</div>

Christopher Dancy wrote:

> > Run it in a sub thread you don’t join on?  
> > -rp
> 
> That’s actually what I’m doing now and then killing off the thread after  
> a few seconds so as not to waste the precious resources of my 1 single  
> ruby process. I was hoping there was a more elegant solution or maybe  
> just a “right” way to do it.

I don’t think there is (though you could commit a patch to trunk that  
would allow for it, perhaps).

[http://emdrb.rubyforge.org](http://emdrb.rubyforge.org)

Mentions it has “synchronous and asynchronous modes”  
Though I’ve never tried it I’ve run into it a few times.  
GL.  
-rp
