Ruby 1.8.1 from Pragmatic Programmers installable, w/problem duplicated in
Win2000 and WinXP - I'm stumped.

Ken.

PS. Thanks Ara.

"Ara.T.Howard" <ahoward / fattire.ngdc.noaa.gov> wrote in message
news:Pine.LNX.4.44.0404272224390.10053-100000 / fattire.ngdc.noaa.gov...
> On Wed, 28 Apr 2004, Ken Hilton wrote:
>
> ken-
>
> so far, this seems to work fine on my box?  what's you platform/arch/ruby
> version, etc?
>
> -a
>
> > Greetings,
> >
> > I added a post earlier today in hopes someone might know right off hand
why
> > the Ruby progam I've written was not functioning as expected.  I didn't
have
> > a lot to go on, nor to share so someone could advise me.  So, I spent
some
> > time stripping my problem child down to its bare minimum and the problem
is
> > persisting.  Can anyone explain to my why this little program seems to
block
> > DRb from responding to calls when a thread in the same app has called
> > gets()?  Here's the code & instructions.  Thanks in advance for any
insight
> > you can provide.  I hope to return the favor in the future.
> >
> > --------------------------
> > # app.rb
> > # Instructions: run this program (app.rb) in one shell THEN run
> > # myclnt.rb in a separate shell.  If the call to "gets" at line
> > # 43 (below) is active, calls to MyServer::service from myclnt.rb
> > # seem to be blocked.  Pressing [enter] (w/a short sleep provided
> > # to better illustrate the problem), allows the DRb calls from
> > # myclnt.rb to be processed, that is right up until the next call
> > # to gets.  Commenting out the call to gets, re-running app.rb,
> > # and then re-running myclnt.rb shows the problem has "gone away."
> > #
> >
> > require 'thread'
> > require 'drb'
> >
> > # MyServer handles calls from myclnt.rb - just returns an I'm alive
message.
> > class MyServer
> >  def service
> >   "MyServer is alive!!!"
> >  end
> > end
> >
> > class App
> >
> >  def initialize()
> >   # array of threads, 1 for DRb and 1 for my command loop,
> >   @services = []
> >  end
> >
> >  def run()
> >
> >   # Start MyServer service and store thread.
> >   svr = MyServer.new();
> >   DRb.start_service('druby://localhost:9000', svr);
> >   @services << DRb.thread;
> >
> >   # Start command loop. *** When "gets" is called DRb appears to block:.
> >   # calls to it from myclnt.rb stall until enter is pressed, thereby
> >   # giving enough cycles to DRb.thread to respond to the request?!?!?
> >   @services << Thread.new {
> >    while true
> >     print "Prompt> "
> >     # comment out the next line and then rerun app.rb and myclnt.rb
> >     #exit if gets.chomp() == "exit";
> >     sleep(1)
> >    end
> >   }
> >
> >   @services.each {|svc| svc.join()}
> >  end
> >
> > end
> >
> > App.new().run();
> >
> > --------------------------
> >
> > # myclnt.rb
> > require 'drb'
> >
> > puts "Running my client..."
> > DRb.start_service(nil,nil)
> >
> > while true
> >  svr = DRbObject.new(nil, 'druby://localhost:9000')
> >  puts "Calling server..."
> >  puts "Server returned: " + svr.service;
> > end
> >
> >
> >
>
> -- 
>
============================================================================
===
> | EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
> | PHONE   :: 303.497.6469
> | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
> | URL     :: http://www.ngdc.noaa.gov/stp/
> | TRY     :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done
>
============================================================================
===
>