From: Bob Calco Date: 2001-12-26T23:03:14+09:00 Subject: [ruby-talk:29440] Tk / IO question I'm experiencing some rather significant performance problems with IO.popen when embedding the logic in a Tk app. I'm using Drb to remotely execute processes and redirect their output to a monitor. Run as a console its (to my naked eye), it's blazing fast, even when the controller/server/monitor are on different machines on the network. However, when run in a Tk GUI -- where the only difference is that Tk.mainloop is keeping the service running vs. DRbObject.thread.join (when run as a console), the slowdown is palpable, I suppose because of the Tk event loop. I didn't benchmark it, but the following IO.popen("#{cmd}","r+") { |ruby| @@jobs += 1 job = @@jobs while ruby.gets monitor.write($_) end ruby.close_write } ...goes from pumping stuff almost instantaneously to the monitor, even if its on a separate machine, to running something like this even when everything is on the same machine , assuming the command is "ruby -e \"for i in 1..10 do;puts i.to_s;end\"" (forgive the crude visualization, which is inaccurate in that it does not illustrate the newline after each output): 1 . . . 2 . . . 3. . . 4. . . 5 . . .6 . . .7. . .8 . . . 9. . . 10 (whereas before it was 12345678910, speedwise). Each tick is about a half a second, though it feels like an eternity. I've tried blocking that whole process into a separate thread and everything but it really seems like the execution of the while loop is what's holding it up. Is there a way to turn the Tk.mainloop off for the duration of the while loop? I'm more of a windows geek but have been trying to learn tk to put together an IDLE-like GUI for a cross-platform control panel solution that controls other machines and apps remotely. Maybe the answer is to run the service as a console and that's it, but I'd like to put a gui on it. Chances are though that my ignorance of Tk is the problem. Sincerely, ____ _ ___ _ | \ | | / ) | | |___/ __ |/_ | __, | | __ __ | \ / \_| \_ | / | |/ / ) / \_ |___/_/\__/ |__/ \___/\_/|_/|__/\___/\__/ Bob Calco Centreville, Virginia ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "Stupidity got us into this mess -- why can't it get us out?" [Will Rogers] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~