# DRB+Mixin, a defect or an usage error?

**URL:** <https://www.ruby-forum.com/t/drb-mixin-a-defect-or-an-usage-error/127663>\
**Category:** Ruby\
**Created:** [January 31, 2008, 5:51am UTC](https://www.ruby-forum.com/t/drb-mixin-a-defect-or-an-usage-error/127663 "2008-01-31T05:51:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yangpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e56c9b/32.png) [@yangpeng](https://www.ruby-forum.com/u/yangpeng)\
**Post date:** [January 31, 2008, 5:51am UTC](https://www.ruby-forum.com/t/drb-mixin-a-defect-or-an-usage-error/127663/1 "2008-01-31T05:51:42Z")

</div>

I found a strange thing when I include a module to a Drb object.I’m  
confused.  
server.rb:require 'drb’require ‘module\_a’  
class ServerHello include TestModule1 def sayHello puts ‘I am  
server’ end endDRb.start\_service(“druby://127.0.0.1:2222”,  
ServerHello.new)DRb.thread.join  
client.rb:  
require ‘drb’ require ‘module\_a’ include TestModule1DRb.start\_service  
info = DRbObject.new(nil, “druby://127.0.0.1:2222”) info.sayHello()  
info.sayHello2  
module\_a.rb:  
require 'drb’module TestModule1 def sayHello2 puts “who am i” endend  
The three files in one path, I run server.rb first, then client.rb. The  
result is.server.rb output:I am serverclietn.rb output:who am iBut my  
expected result is:server.rb output both “I am server” and “who am i”  
the “sayHello2” is executed in local, not remote…(or exactly, it’s  
“client invoke server, server invoke client backly”, for if we changed  
“puts “who am i”” to “puts self”, the result is “DRbObject”)  
If I comments the “include TestModule1” of client.rb, the result is  
good.But this is not I want, for there are many standard code share  
between server and client.  
It’s it a defect or my usage error?

---

<div class="post-metadata">

**Author:** ![yangpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e56c9b/32.png) [@yangpeng](https://www.ruby-forum.com/u/yangpeng)\
**Post date:** [January 31, 2008, 6:41pm UTC](https://www.ruby-forum.com/t/drb-mixin-a-defect-or-an-usage-error/127663/2 "2008-01-31T18:41:06Z")

</div>

2008/1/30 yangpeng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> end  
> end  
> include TestModule1
> 
> But this is not I want, for there are many standard code share between server and client.  
> It’s it a defect or my usage error

Wow, this is surprising. I would really appreciate some enlightenment  
by somebody more experienced with DRB, but I would call this a bug.

Daniel Brumbaugh K.

---

<div class="post-metadata">

**Author:** ![yangpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e56c9b/32.png) [@yangpeng](https://www.ruby-forum.com/u/yangpeng)\
**Post date:** [February 1, 2008, 2:02am UTC](https://www.ruby-forum.com/t/drb-mixin-a-defect-or-an-usage-error/127663/3 "2008-02-01T02:02:04Z")

</div>

yeah, then how can I report this defect, if it is a defect? \> Date: Fri,  
1 Feb 2008 02:40:02 +0900\> From: removed\_email\_address@domain.invalid\> Subject: Re:  
DRB+Mixin, a defect or an usage error?\> To: removed\_email\_address@domain.invalid\> \>  
2008/1/30 yangpeng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):\> \> \> I found a strange thing  
when I include a module to a Drb object.\> \> I’m confused.\> \>\> \>  
module\_a.rb:\> \>\> \> require ‘drb’\> \> module TestModule1\> \> def sayHello2\>

> puts “who am i”\> \> end\> \> end\> \>\> \> server.rb:\> \>\> \> require ‘drb’\> \>  
> require ‘module\_a’\> \>\> \> class ServerHello\> \> include TestModule1\> \> def  
> sayHello\> \> puts ‘I am server’\> \> end\> \> end\> \>\> \>  
> DRb.start\_service(“druby://127.0.0.1:2222”, ServerHello.new)\> \>  
> DRb.thread.join\> \>\> \>\> \> client.rb:\> \>\> \> require ‘drb’\> \> require  
> ‘module\_a’\> \> include TestModule1\> \> DRb.start\_service\> \> info =  
> DRbObject.new(nil, “druby://127.0.0.1:2222”)\> \> info.sayHello()\> \>  
> info.sayHello2\> \>\> \> The three files in one path, I run server.rb first,  
> then client.rb.\> \> The result is\> \>\> \> server.rb output:\> \> I am server\>
> 
> > > client.rb output:\> \> who am i\> \>\> \> But my expected result is:\> \>\>  
> > > server.rb output both “I am server” and “who am i”\> \>\> \> the  
> > > “sayHello2” is executed in local, not remote. (or exactly, it’s “client  
> > > invoke server, server invoke client backly”,\> \> for if we changed “puts  
> > > “who am i”” to “puts self”, the result is “DRbObject”)\> \> If I comments  
> > > the “include TestModule1” of client.rb, the result is good.\> \> But this  
> > > is not I want, for there are many standard code share between server and  
> > > client.\> \> It’s it a defect or my usage error\> \> \> Wow, this is  
> > > surprising. I would really appreciate some enlightenment\> by somebody  
> > > more experienced with DRB, but I would call this a bug.\> \> Daniel  
> > > Brumbaugh K.\>

---

<div class="post-metadata">

**Author:** ![yangpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e56c9b/32.png) [@yangpeng](https://www.ruby-forum.com/u/yangpeng)\
**Post date:** [February 1, 2008, 9:25pm UTC](https://www.ruby-forum.com/t/drb-mixin-a-defect-or-an-usage-error/127663/4 "2008-02-01T21:25:51Z")

</div>

2008/1/31 yangpeng [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> yeah, then how can I report this defect, if it is a defect?

I’ve spent some more time looking through the various Ruby test  
suites, but I can’t find any tests for this behavior. It’s definitely  
a bug. I believe the bug report for this should go to  
[http://rubyforge.org/tracker/?func=add&group\_id=426&atid=1698](http://rubyforge.org/tracker/?func=add&group_id=426&atid=1698)  
under the category “Misc / Other Standard Library”

The issue seems to be that DRb is including the client version of  
modules if it is available, whereas it should always include the  
server one. To use RSpec in your example:  
info.kind\_of?(TestModule1).should be\_false

or generically  
describe DRb::DRbObject do

Daniel Brumbaugh K.

---

<div class="post-metadata">

**Author:** ![yangpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e56c9b/32.png) [@yangpeng](https://www.ruby-forum.com/u/yangpeng)\
**Post date:** [February 1, 2008, 9:27pm UTC](https://www.ruby-forum.com/t/drb-mixin-a-defect-or-an-usage-error/127663/5 "2008-02-01T21:27:01Z")

</div>

On Feb 1, 2008 2:24 PM, Daniel Brumbaugh K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The issue seems to be that DRb is including the client version of  
> modules if it is available, whereas it should always include the  
> server one. To use RSpec in your example:  
> info.kind\_of?(TestModule1).should be\_false
> 
> or generically  
> info.class.included\_modules.should == [Kernel]

Daniel Brumbaugh K.

blast, tabs don’t do the same thing in browsers they do in text editors
