From: Hugh Sasse Date: 2005-11-04T05:53:19+09:00 Subject: Re: DRb recycled objects. On Fri, 4 Nov 2005, Kevin Brown wrote: > I started this as a question but figured out the answer while I was > researching, so I'm posting this here for others that may have the same > problem. > > The error I received from my code was as follows: > > (druby://*:9000) /usr/lib/ruby/1.8/drb/drb.rb:375:in `_id2ref': 0xdbe53cf6 is > recycled object (RangeError) [stacktrace] > > This was happening consistantly from the same place in the code. I finally > tracked down the line that was giving me grief, and the issue was that I had > a method called Order#id. When I was running the code without DRb, this > worked just fine, but calling id on a DRb proxy object will get you its DRb > object id. I was returning this value, etc. > > I fixed the problem by changing the method name to order_id, so I know how to You will now run into a problem when you port this to Rails :-) [Rails uses the method #{name}_id to reference the primary key in table "name" (cf Foreign Key)] > avoid the error, but I would still like a little more explaination as to why > exactly this occurred so I can get DRb just that much clearer in my mind. :-) -------------------------------------------------------------- Object#id obj.id => fixnum ------------------------------------------------------------------------ Soon-to-be deprecated version of +Object#object_id+. uniquely identifies an object in the Ruby process. I'm not sure how DRb uses it, but probably to make sure the objects are distinct. > > Thank you for flagging this up. HTH Hugh