问题
Using Python 2.6, Twisted 10.1, and GTK+ 2.22, with latest pygtk installed, I'm having problems on shutdown. When I close my application and shut down the reactor (using the gtk2reactor
of course), the application simply freezes.
I've poked around the twisted source and added debug messages. What ends up happening is, the 'shutdown'
event fires, PortableGtkReactor.crash
is called, which calls gtk.main_quit
. The event gets processed at the end of ReactorBase.runUntilCurrent
. When the function returns, control goes to ReactorBase.iterate
, which returns control to PortableGtkReactor.simulate
, which goes back to... the gtk.main()
call. It looks like gtk
just doesn't quit.
Unfortunately, when I put together a very simple example with twisted and the gtk "Hello World" sample, everything shut down correctly. It must be something my application is doing. Until I can figure it out further, though...
What might be causing this? Like what could an app do that causes gtk to not quit? The app worked fine on Gtk 2.12, with Python 2.5 and Twisted 8.1, if that helps at all.
回答1:
As from this question it seems to come from importing the win32ui
module. But I think the underlying problem is deeper..
EDIT: Seems to be a problem with my particular install of Windows 7 and whatever else is here.
回答2:
Threads, perhaps? The Twisted reactor joins all threads on shutdown, and if you're doing something in a callInThread
that hangs, your loop may be unable to stop. (I'm not sure what the behavior would be if you're starting your own threads, either.)
来源:https://stackoverflow.com/questions/4308346/twisted-gtk-shutdown-not-working-properly