--------------080705030905040009070909 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 13.10.2008 19:39, Bryan Richardson wrote: > I have a long running Ruby simulation in which data is stored to Ruby > hashes throughout the simulation. I'd like to be able to access the > hashes in memory from another Ruby script while the simulation is still > running to see what the progress of the simulation is (rather than > printing to the screen, using log4r, etc. Is this possible? If so, any > suggestions how to do so? Please look into DRb. For pure status updates I would push the current state to the other process as opposed to pulling it because this does not need synchronization in the simulation. You can find a working toy example attached. Kind regards robert --------------080705030905040009070909 Content-Type: text/plain; name tatus.rb" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename tatus.rb" #!/bin/env ruby require 'drb' require 'monitor' URI druby://127.0.0.1:13344" class Status def initialize self.extend MonitorMixin self.finished end def finished synchronize do @finished end end def finished) synchronize do @finished end end def done self.finished 00 end end fork do status tatus.new DRb.start_service URI, status loop do st tatus.finished printf "Finished %5.1f%%\n", st break if st > 00 sleep 2 end DRb.stop_service puts 'client done' end DRb.start_service st RbObject.new nil, URI 100.times do |i| sleep((rand(100) + 1) / 100.0) st.finished end st.done puts 'server done' DRb.stop_service --------------080705030905040009070909--