From: "Ara.T.Howard" Date: 2004-02-25T14:54:48+09:00 Subject: io/nonblock - blocks w/threads? this program does not work as expected w/o inserting the 'Thread.critical' bits - i must say i do not understand why, can someone help me understand? require 'tk' require 'open3' require 'io/nonblock' $VERBOSE=nil r=TkRoot.new l=TkLabel.new r, :text=>`ruby -e "p Time.now"` l.pack command='ruby -e "loop{p Time.now; sleep 1}"' i,o,e = Open3::popen3 command i.close text = nil Thread.new do loop do rios, = select [o,e], nil, nil rios.map do |rio| next if rio.eof? Thread.critical = true # blocks w/o this rio.nonblock{ text = rio.read } Thread.critical = false # blocks w/o this l.configure :text=>text end end end Tk.mainloop is this an o.k. technique to prevent a non-blocking read not to hand a multi-threaded ap? i'm think of adding an asychronous processing option to my session library using this feature... actually i suppose it'd always be o.k. for this to be there... -a -- =============================================================================== | 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 ===============================================================================