Python Tkinter after method silently exits

Steve Ward ward@mit.edu
Mon Feb 20 12:42:00 GMT 2006


On upgrading to the latest 1.5.19-4 cygwin release, I
find that several previously working python programs
began mysteriously exiting. I've boiled the problem
down to a skeletal test program (attached), which runs
under the prior 1.5.18-1 release but exits under 1.5.19-4.
The second thread seems necessary to stimulate the failure;
even commenting out the sleep(100) to make it return
immediately avoides the spurious exit. When the second
thread is running, the self.root.after(...) call
apparently causes a silent exit rather than returning.
Any help/ideas would be appreciated...
- Steve Ward
# Demonstrate python/Tkinter threading bug
class App:
 def __init__(self, root):
 self.root = root
 self.update_loop()
 # Start a second thread, to do whatever...
 self.thread = threading.Thread(target=self.second_thread)
 self.thread.start()
 def update_loop(self):
 print >>sys.stderr, "*** update_loop"
 self.root.after(400, self.update_loop)
 def second_thread(self):
 sleep(100)
if __name__ == "__main__":
 root = TK.Tk()
 app = App(root)
 root.mainloop();
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/


More information about the Cygwin mailing list

AltStyle によって変換されたページ (->オリジナル) /