From: m_seki@... Date: 2003-01-12T15:40:33+09:00 Subject: Re: drb bug? Hi, > > for example ... # sorry, it is untested. > > > > block = Proc.new { |val| puts val } > > (0..9).each do |i| > > server.register(100*i + 1, &block) > > end > > > > Same problem, after this change. > > But you are right about GC being involved. GC.disable in the client > prevents the problem from happening. So something else is getting > collected. (Is it possible that the proc is copied internally?) oops. it is drb's problem. I have noticed this behavior just now. blk = Proc.new { |x| } p blk.__id__ # -> 537833186 p blk # -> # def foo(b0, &b) p [b0.__id__, b0] p [b.__id__, b] end foo(blk, &blk) # -> [537833186, #] # -> [537966706, #] In drb, The given block cannot be used after a method is returned. You can avoid a problem if using the Proc object instead of giving block. --- server.rb ... class Server ... def register(value, action) ## not &action @observers << [value, action] end ... end ... --- client.rb ... block = Proc.new { |val| puts val } (0..9).each do |i| server.register(100*i + 1, block) ## not &block end ... Or, use DRb::TimerIdConv. --- client.rb require 'drb' require 'drb/timeridconv' DRb.install_id_conv(DRb::TimerIdConv.new) DRb.start_service() server = DRbObject.new(nil, 'druby://localhost:9500') block = Proc.new { |val| puts val } (0..9).each do |i| server.register(100*i + 1, &block) end sleep