can anyone think of a more elegant way to do this:
~ > cat drb_fork.rb
require 'drb/drb'
def drb_fork obj
pipe = IO.pipe
fork do
pipe[0].close
pipe = pipe[1]
DRb.start_service nil, obj
pipe.write DRb.uri
pipe.close
DRb.thread.join
end
pipe[1].close
pipe = pipe[0]
uri = pipe.read
DRb.start_service nil, nil rescue nil
DRbObject.new nil, uri
end
a = drb_fork
a << 42
p a.first
~ > ruby drb_fork.rb
42
??
thanks.
-a
···
--
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen
===============================================================================
Ara.T.Howard wrote:
can anyone think of a more elegant way to do this:
~ > cat drb_fork.rb
require 'drb/drb'
def drb_fork obj
pipe = IO.pipe
fork do
pipe[0].close
pipe = pipe[1]
DRb.start_service nil, obj
pipe.write DRb.uri
pipe.close
DRb.thread.join
end
pipe[1].close
pipe = pipe[0]
uri = pipe.read
DRb.start_service nil, nil rescue nil
DRbObject.new nil, uri
end
a = drb_fork
a << 42
p a.first
~ > ruby drb_fork.rb
42
Maybe this:
http://raa.ruby-lang.org/project/detach/
I've never used it, but it looks interesting. (I suspect it does the same as you do, though.)
can anyone think of a more elegant way to do this:
~ > cat drb_fork.rb
require 'drb/drb'
def drb_fork obj
pipe = IO.pipe
fork do
pipe[0].close
pipe = pipe[1]
DRb.start_service nil, obj
pipe.write DRb.uri
^^^^^^^^^^^^^^^^^^
I take it this is the important line you're looking for?
pipe.close
DRb.thread.join
end
pipe[1].close
pipe = pipe[0]
uri = pipe.read
DRb.start_service nil, nil rescue nil
DRbObject.new nil, uri
end
a = drb_fork
a << 42
p a.first
Use Rinda::RingServer:
http://segment7.net/projects/ruby/drb/rinda/ringserver.html
The description above is the most verbose way to perform service
discovery, since you get a DRb server running as a name service.
Instead you can just plug your front object into the RingServer, if you
only ever need one front.
···
Ara.T.Howard (Ara.T.Howard@noaa.gov) wrote:
--
Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
it does look pretty nice - i didn't know about the drbunix:// uri style -
that's a nice trick since the code won't run w/o fork and there for should be
able to do this.
thanks for the pointer.
-a
···
On Thu, 15 Jul 2004, Joel VanderWerf wrote:
Ara.T.Howard wrote:
can anyone think of a more elegant way to do this:
~ > cat drb_fork.rb
require 'drb/drb'
def drb_fork obj
pipe = IO.pipe
fork do
pipe[0].close
pipe = pipe[1]
DRb.start_service nil, obj
pipe.write DRb.uri
pipe.close
DRb.thread.join
end
pipe[1].close
pipe = pipe[0]
uri = pipe.read
DRb.start_service nil, nil rescue nil
DRbObject.new nil, uri
end
a = drb_fork
a << 42
p a.first
~ > ruby drb_fork.rb
42
Maybe this:
http://raa.ruby-lang.org/project/detach/
I've never used it, but it looks interesting. (I suspect it does the
same as you do, though.)
--
EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
A flower falls, even though we love it;
and a weed grows, even though we do not love it. --Dogen
===============================================================================