扭曲+ Gtk - 关闭无法正常工作
使用 Python 2.6、Twisted 10.1 和 GTK+ 2.22,并安装了最新的 pygtk,我在关机时遇到问题。当我关闭应用程序并关闭反应器(当然使用 gtk2reactor)时,应用程序就会冻结。
我研究了扭曲的源代码并添加了调试消息。最终发生的情况是,'shutdown'
事件触发,PortableGtkReactor.crash
被调用,进而调用 gtk.main_quit
。该事件在 ReactorBase.runUntilCurrent
结束时进行处理。当函数返回时,控制权转到ReactorBase.iterate,后者将控制权返回给PortableGtkReactor.simulate,后者返回到... gtk.main()调用。看起来gtk
就是没有退出。
不幸的是,当我将一个非常简单的示例与twisted 和gtk“Hello World”示例放在一起时,一切都正确关闭。这一定是我的应用程序正在做的事情。不过,直到我能进一步弄清楚……
可能是什么原因造成的?比如应用程序会做什么导致 gtk 不退出?该应用程序在 Gtk 2.12、Python 2.5 和 Twisted 8.1 上运行良好(如果有帮助的话)。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从这个问题看来,通过导入
win32ui
模块。但我认为潜在的问题更深层次。编辑:似乎是我的 Windows 7 的特定安装以及这里的其他内容的问题。
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.
也许是线程? Twisted 反应器在关闭时连接所有线程,如果您在挂起的
callInThread
中执行某些操作,则循环可能无法停止。 (我也不确定如果您启动自己的线程,行为会是什么。)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.)