本文介绍了mod_wsgi的错误 - 类.__ dict__在受限模式下无法访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这开始咬我们的屁股我们的生产服务器上真的很难。我们看到这个偶尔(每周1要求)。当时我们发现了那是因为的mod_wsgi的做一些时髦的东西在一些CONFIGS。由于我们无法跟踪的原因的错误,我们决定,它并不需要即时关注。

今天然而,在我们的生产服务器的1这真的发生了所有服务器请求的10%;这是所有服务器请求的10%,与此同样的错误失败:

 的mod_wsgi(PID = 1718):目标WSGI脚本/installation/dir/our-program/prod-dispatch.wsgi不能加载Python模块。
mod_wsgi的(PID = 1718):发生异常处理WSGI脚本/installation/dir/our-program/prod-dispatch.wsgi。
回溯(最近通话最后一个):
  文件/installation/dir/our-program/prod-dispatch.wsgi,7号线,上述<&模块GT;
    从pyramid.paster进口get_app
  文件\"/installation/dir/venv/local/lib/python2.7/site-packages/pyramid-1.3a6-py2.7.egg/pyramid/paster.py\", 12号线,上述<&模块GT;
    从pyramid.scripting进口prepare
  文件\"/installation/dir/venv/local/lib/python2.7/site-packages/pyramid-1.3a6-py2.7.egg/pyramid/scripting.py\", 1号线,上述<&模块GT;
    从pyramid.config进口global_registries
  文件\"/installation/dir/venv/local/lib/python2.7/site-packages/pyramid-1.3a6-py2.7.egg/pyramid/config/__init__.py\",线61,上述<模块>
    从pyramid.config.assets进口AssetsConfiguratorMixin
  文件\"/installation/dir/venv/local/lib/python2.7/site-packages/pyramid-1.3a6-py2.7.egg/pyramid/config/assets.py\",线83,上述<模块>
    @implementer(IPackageOverrides)
  文件\"/installation/dir/venv/local/lib/python2.7/site-packages/zope.interface-3.8.0-py2.7-linux-x86_64.egg/zope/interface/declarations.py\",线480,在__
    classImplements(OB,* self.interfaces)
  文件\"/installation/dir/venv/local/lib/python2.7/site-packages/zope.interface-3.8.0-py2.7-linux-x86_64.egg/zope/interface/declarations.py\",线445,CL中
    规格= implementedBy(CLS)
  文件\"/installation/dir/venv/local/lib/python2.7/site-packages/zope.interface-3.8.0-py2.7-linux-x86_64.egg/zope/interface/declarations.py\",线285,在IM
    规格= CLS .__字典__。获得(__ implemented__')
RuntimeError:类.__ dict__在受限模式下无法访问

Ubuntu的precise,64位,与最新的阿帕奇,mod_wsgi的,Python 2.7版中的后台的模式下使用mpm_worker + mod_wsgi的。这是服务器上运行的唯一程序,并只存在一个WSGI $间在配置p $ PTER。这是因为mpm_worker产生新的线程或什么的?更重要的是 - 我们如何解决它。

我们有以下的细分要求的基础上的cookie 4守护进程。

  WSGIPythonOptimize 1WSGIDaemonProcess sticky01流程= 1线程= 16的显示名称=%{}集团
WSGIDaemonProcess sticky02流程= 1线程= 16的显示名称=%{}集团
WSGIDaemonProcess sticky03流程= 1线程= 16的显示名称=%{}集团
WSGIDaemonProcess sticky04流程= 1线程= 16的显示名称=%{}集团<虚拟主机*:81>
    ...
    WSGIRestrictProcess sticky01 sticky02 sticky03 sticky04
    WSGIProcessGroup%{ENV:PROCESS}
    ...    WSGIScriptAlias​​ / /installation/dir/our-program/prod-dispatch.wsgi
< /虚拟主机>


解决方案

已经知道了好半天多个subinter preters不沿C扩展打好。然而,我没有意识到的是,默认的设置是非常不幸的。 明确规定,对于WSGIApplicationGroup指令的默认值是%{}资源的其效果应是

This means that for each Host: header ever encountered while accessing the server the mod_wsgi kindly spawns a new subinterpreter, for which the C extensions are then loaded.

I had unknowingly triggered the error by accessing localhost.invalid:81 with links browser on this local server causing 1 of our 4 WSGIDaemonProcesses to fail for all future incoming requests.

Summa summarum: always when using mod_wsgi with pyramid or any other framework that uses C extensions, make sure that WSGIApplicationGroup is always set to %{GLOBAL}. In other words, the result of using the default settings will cause you to shoot yourself in the foot, after which you might want to shoot yourself in the head too.

这篇关于mod_wsgi的错误 - 类.__ dict__在受限模式下无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 09:04