使用 WSGI apache 模块执行 Qt4 应用程序时出错
我在使用 WSGI 3.3 和 Qt4 应用程序时遇到问题。看来 QGraphicsScene 的项目无法调用 childItem() 方法。以下测试脚本在从命令行调用时运行良好,但在作为 WSGI 应用程序调用时永远不会完成。我注意到使用 WSGI v3.3 时存在此问题,但旧版本(2.8)则不存在此问题。
childItems() 方法似乎挂起并且应用程序变得无响应。
关于可能发生的事情有任何线索吗?
from PyQt4.QtGui import *
import sys
# Show print msgs in apache logs
sys.stdout = sys.stderr
import os
# Allows apache to use DISPLAY. The command "xhost +" could be temporarily required to start Qt applications from the web server
os.environ["DISPLAY"]=":0.0"
QApp = None
def application(environ, start_response):
global QApp
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
qt_test()
return [output]
def qt_test():
QApp = QApplication(["TEST"])
scene = QGraphicsScene()
obj = QGraphicsRectItem()
scene.addItem(obj)
print "EMPTY LIST", obj.childItems()
obj2 = QGraphicsRectItem()
obj2.setParentItem(obj)
print "CHILDREN", obj.childItems()
print "FINISH"
return
if __name__ == "__main__":
qt_test()
环境(工作):python 2.6.4,apache 2.2.14,mod-wsgi 2.8,qt 4.6.2,python-qt 4.7.2
环境(问题):python 2.6.6,2.2.16,mod-wsgi 3.3, qt 4.6.3、python-qt 4.7.3
I'm getting problems with WSGI 3.3 and Qt4 applications. It seems that items of a QGraphicsScene cannot call the childItem() method. The following test script works well when called from the command line, but never finishes when called as WSGI application. I have noticed that this problem is present when using WSGI v3.3 but not with older (2.8) versions.
childItems() method seem to hang and the application becomes unresponsive.
Any clue about what could be happening?
from PyQt4.QtGui import *
import sys
# Show print msgs in apache logs
sys.stdout = sys.stderr
import os
# Allows apache to use DISPLAY. The command "xhost +" could be temporarily required to start Qt applications from the web server
os.environ["DISPLAY"]=":0.0"
QApp = None
def application(environ, start_response):
global QApp
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
qt_test()
return [output]
def qt_test():
QApp = QApplication(["TEST"])
scene = QGraphicsScene()
obj = QGraphicsRectItem()
scene.addItem(obj)
print "EMPTY LIST", obj.childItems()
obj2 = QGraphicsRectItem()
obj2.setParentItem(obj)
print "CHILDREN", obj.childItems()
print "FINISH"
return
if __name__ == "__main__":
qt_test()
environment (working): python 2.6.4, apache 2.2.14, mod-wsgi 2.8, qt 4.6.2, python-qt 4.7.2
environment (problem): python 2.6.6 , 2.2.16, mod-wsgi 3.3, qt 4.6.3, python-qt 4.7.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
mod_wsgi 小组的人向我指出了这个问题:
People from the mod_wsgi group pointed me to the problem: