first, thanks for the responses, ruby really is a great language.
My delima is that I'm trying to multithread the actions and store the
results in a hash with the hostname as key
to redefine the issue, for each host I need a thread and I expect a
result, then I'd like to be able to see the result in a
hash[host][result]
but I'm having trouble mixing the hash with the thread. maybe I'm going
about this all wrong. (this is outputting to a rails view, which is why
i have "@vars"
I have
@threads = []
@resulthash = Hash.new(0)
@hostarray.each do |host|
threads << Thread.new(host) do |myhost|
@resulthash = { :myhost => {

ackages => @mypackages,
:result => doXMLquery(host,@mypackages)} }
logger.info("host = " + host + ", result = " +
@resulthash[:myhost][:result])
end
end
@threads.each {|thr| thr.join }
logger.info("result of threads..")
@hostarray.each do |myhost|
logger.info("host = " + myhost + ", result = " +
@resulthash[:myhost][:result])
end
logger output
host = hostX, result = --data returned from hostX--
host = hostY, result = --data returned from hostY--
result of threads..
host = hostX, result = --data returned from hostY--
host = hostY, result = --data returned from hostY--
I'm clearly loosing context of the [:host][:result] in the final two
lines.
any pointers?
thanks
-zaq
--
Posted via
http://www.ruby-forum.com/.