Thank you for your reply. From: Juju SL <jujusl / free.fr> Subject: Re: Tk : non blocking Tk.mainloop Date: Tue, 3 May 2011 05:46:55 +0900 Message-ID: <beee0c75cd89cf0fa720304393532c71 / ruby-forum.com> > So, I patched manually the tk.rb file : You don't need manual patch. Please use "patch" command. # Or, packaged version of tk.rb is not a normal one of ruby192p0? # If so, please tell me the version of your package. > Unfortunately, my small scripts ends with an exception : Hmmm... Maybe, I misunderstood the reason of the trouble. The exception is not important. It is a normal situation when a Tcl/Tk interpreter is deleted at exit. I want to know when and how Tk.mainloop exits. Could you send me a *FULL* debug log with tk.rb (patched by previous (ruby-talk:382536) patch) patched by the following? --- tk.rb~ 2011-05-02 18:16:29.000000000 +0900 +++ tk.rb 2011-05-03 11:18:17.000000000 +0900 @@ -1852,32 +1852,56 @@ TclTkLib.mainloop(check_root) else ### Ruby 1.9 !!!!! +p :log001 unless TkCore::INTERP.default_master? +p :log002 # [MultiTkIp] slave interp ? return TkCore::INTERP._thread_tkwait('window', '.') if check_root end +p :log003 # like as 1.8, withdraw a root widget before calling Tk.mainloop TkCore::INTERP._eval_without_enc('catch {unset __initial_state_of_rubytk__}') +p :log004 INTERP_THREAD.run +p :log005 begin TclTkLib.set_eventloop_window_mode(true) +p :log006 if check_root +p :log007 INTERP_MUTEX.synchronize{ +p :log008 INTERP_ROOT_CHECK.wait(INTERP_MUTEX) +p :log009 status = INTERP_THREAD_STATUS.value +p [:log010, status] if status && TkCore::INTERP.default_master? INTERP_THREAD_STATUS.value = nil if $SAFE < 4 +p :log011 raise status if status.kind_of?(Exception) end +p :log012 } else - INTERP_THREAD.value +p :log013 + # INTERP_THREAD.value + begin + INTERP_THREAD.value + rescue Exception => e +p [:log014, e] + raise e + end end + rescue Exception => e +p [:log015, e] + raise e ensure +p :log016 TclTkLib.set_eventloop_window_mode(false) end +p :log017 end end -- Hidetoshi NAGAI (nagai / ai.kyutech.ac.jp) Department of Artificial Intelligence, Kyushu Institute of Technology