J
john casu
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.
Thanks,
john c.
-------------------------------------------------------------------
require 'drb'
require 'thread'
foo_serve = Thread.new do
system("/bin/bash -c \"foo_server\"")
end
# sleep 5.0
DRb.start_service
foo = nil
until (foo)
begin
foo = DRbObject.new(nil, 'druby://hobbes:7777')
rescue StandardError, DRbConnError
p "got exception"
ensure
sleep 0.05
end
end
puts foo.call_remote_foo(0, "run")
puts foo.call_remote_foo(0, "exit")
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.
Thanks,
john c.
-------------------------------------------------------------------
require 'drb'
require 'thread'
foo_serve = Thread.new do
system("/bin/bash -c \"foo_server\"")
end
# sleep 5.0
DRb.start_service
foo = nil
until (foo)
begin
foo = DRbObject.new(nil, 'druby://hobbes:7777')
rescue StandardError, DRbConnError
p "got exception"
ensure
sleep 0.05
end
end
puts foo.call_remote_foo(0, "run")
puts foo.call_remote_foo(0, "exit")