From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2001-02-23T06:10:03+09:00 Subject: [ruby-talk:11347] Re: dRuby problem with Threads(still need solution - Threads problem?) OK, I'm gonna try posting this for the third time... could be duplicates, but it doesn't seem to want to go. In article , Clemens Wyss wrote: >ptkwt@shell1.aracnet.com (Phil Tomson) wrote in >: > >>This is a strange one - then again It's about 11:20PM so everything is >>looking strange. >> >...for me it's 11:20am > >I let the server and the client run on the same W2K-box. >This is the slightly modified client code: >#### client >require 'drb' >machine = "localhost" >command = "this is the command" >DRb.start_service() >drbObj = DRbObject.new(nil, "druby://#{machine}:9000") >def threaded(drbObj, command) > thread = Thread.new() { > p "start" > drbObj.eval_it(command) > p "end" > } #thread > thread.join() # Phil you *forgot* this one! Actually, no I didn't forget this - I don't want it. Adding thread.join here effectively blocks so that execution doesn't continue till after the thread finishes. This is a distributed app that sends commands to several machines running various Unix and Windows OS's. The intent is for it to send a command and then go look for the next available machine (not to wait around for the current target to finish). >end >#DRb.stop_service() >def single(drbObj, command) > p "start" > drbObj.eval_it(command) > p "end" >end > >single(drbObj, command) >threaded(drbObj, command) >##### > >Note the thread.join()-line. Looks like windows terminates immediately >(i.e. tearing down your thread -> this could be the reason for your error >messages!) without the join-call. Now calling my code sometimes (not >allways though) produces the following error on the client side!: > >"/cygdrive/d/ruby/lib/ruby/site_ruby/1.6/drb/drb.rb:189:in `open': >Invalid argument - "connect(2)" (Errno::EINVAL) > from E:\drb_cl.rb:12:in `join' > from E:\drb_cl.rb:12:in `threaded' > from E:\drb_cl.rb:22 >" > >Looks like there is still a *slight* problem, just a different one. >Clemens > I didn't see that problem when I added the join (just to try it out). So my question still remains - why does the dRuby server care if a method was called from the client's main thread of execution or from another spawned thread? It works from Linux -> Linux, but not from Linux -> Windows (server running on Windows). I believe it used to work when all my machines were running 1.6.1 with drb 1.2.2 (now we're all at 1.6.2 with drb 1.3) Phil