From: Eric Hodel Date: 2005-07-24T08:15:50+09:00 Subject: Re: Catching DRb exceptions ?? On 23 Jul 2005, at 01:10, john casu wrote: > I have a simple problem. > I want to launch a DRb server from my program (in my case a > parallel MPI program, > where the zero rank process is the actual DRb server), and then > connect to it. > > If I place a long enough sleep before invoking DRbObject.new, then > everything > is groovy, and things proceed as intended. If I don't, then I get > a DRbConnError > exception when DRB tries to connect to the server (which hasn't > started up yet) > > My problem is that I am unable to catch the exception that > DRbObject.new raises > (i.e, I never see the "got exception" message in the attached code > below), and > hence I am at the mercy of race conditions for this to work in a > consistent way > without an excessively long sleep. > > Can anyone please point out to me where I'm being a moron, and what > I'm doing wrong ? > I'm running ruby-1.8.3 on Fedora Core 4 Linux. $ ruby drb.rb /usr/local/lib/ruby/1.8/drb/drb.rb:733:in `open': druby://hobbes:7777 - # (DRb::DRbConnError) from /usr/local/lib/ruby/1.8/drb/drb.rb:726:in `each' from /usr/local/lib/ruby/1.8/drb/drb.rb:726:in `open' from /usr/local/lib/ruby/1.8/drb/drb.rb:1186:in `initialize' from /usr/local/lib/ruby/1.8/drb/drb.rb:1166:in `open' from /usr/local/lib/ruby/1.8/drb/drb.rb:1082:in `method_missing' from /usr/local/lib/ruby/1.8/drb/drb.rb:1081:in `with_friend' from /usr/local/lib/ruby/1.8/drb/drb.rb:1081:in `method_missing' from drb.rb:5 ^^^^^^^^ [ ~ ] [16:14] drbrain@kaa$ cat -n drb.rb 1 require 'drb' 2 3 DRb.start_service 4 foo = DRbObject.new(nil, 'druby://hobbes:7777') 5 puts foo.call_remote_foo(0, "run") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 6 DRb doesn't attempt to connect until you try to use the remote object. You may want to look into Rinda to automatically find live DRb services: http://segment7.net/projects/ruby/drb/rinda/ringserver.html -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04