使用 WSGI apache 模块执行 Qt4 应用程序时出错

发布于 2024-12-12 02:46:38 字数 1337 浏览 0 评论 0原文

我在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

喜爱皱眉﹌ 2024-12-19 02:46:38

mod_wsgi 小组的人向我指出了这个问题:

您是否设置:

WSGIApplicationGroup %{GLOBAL}

在 Apache 配置中。

People from the mod_wsgi group pointed me to the problem:

Are you setting:

WSGIApplicationGroup %{GLOBAL}

in Apache configuration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文