gpt4 book ai didi

python - 使用 uWSGI 时 Django 中内置 Python 函数的 NameError

转载 作者:太空宇宙 更新时间:2023-11-04 06:27:14 25 4
gpt4 key购买 nike

我在带有 uWSGI (0.9.8) 的 Ubuntu 10.10(64 位)上运行 Django 1.3 + Python 2.6。 然而,偶尔我会在uwsgi.log中发现一些奇怪的日志,报告'getattr', 'isinstance' is not defined。但它们不是 Python 的内置函数吗?为什么 Django 找不到它们?这种情况在 uwsgi 服务器重启时流量低时不常发生,而在流量大且服务器运行一小会儿时经常出现。

我确定我的 Django 应用程序没有任何问题,但我不确定这是否是 Django、uWSGI 甚至 Python 2.6 中的错误。

更新:最新版本的 uWSGI 似乎没有这个了。

详细日志:

Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 48, in apport_excepthook
if not enabled():
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 24, in enabled
return re.search('^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
File "/usr/lib/python2.6/re.py", line 142, in search
return _compile(pattern, flags).search(string)
File "/usr/lib/python2.6/re.py", line 236, in _compile
if isinstance(pattern, _pattern_type):
NameError: global name 'isinstance' is not defined

Original exception was:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-
packages/django/core/handlers/wsgi.py", line 258, in __call__
set_script_prefix(base.get_script_name(environ))
File "/usr/local/lib/python2.6/dist-
packages/django/core/handlers/base.py", line 239, in get_script_name
if settings.FORCE_SCRIPT_NAME is not None:
File "/usr/local/lib/python2.6/dist-
packages/django/utils/functional.py", line 277, in __getattr__
return getattr(self._wrapped, name)
NameError: global name 'getattr' is not defined Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-
packages/django/core/handlers/wsgi.py", line 258, in __call__
set_script_prefix(base.get_script_name(environ))
File "/usr/local/lib/python2.6/dist-
packages/django/core/handlers/base.py", line 252, in get_script_name
return force_unicode(environ.get('SCRIPT_NAME', u''))
File "/usr/local/lib/python2.6/dist-packages/django/utils/encoding.py",
line 64, in force_unicode
if isinstance(s, unicode):
NameError: global name 'isinstance' is not defined Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 48, in apport_excepthook
if not enabled():
File "/usr/lib/python2.6/dist-packages/apport_python_hook.py", line 24, in enabled
return re.search('^\s*enabled\s*=\s*0\s*$', conf, re.M) is None
File "/usr/lib/python2.6/re.py", line 142, in search
return _compile(pattern, flags).search(string)
File "/usr/lib/python2.6/re.py", line 236, in _compile
if isinstance(pattern, _pattern_type):
NameError: global name 'isinstance' is not defined

最佳答案

你能试试最新的提示吗?它看起来像是一个应该在 0.9.9-dev 中修复的引用计数错误

如果您可以确认它解决了您的问题,我将发布仅应用此修复程序的更新版本。

非常感谢您的报告

关于python - 使用 uWSGI 时 Django 中内置 Python 函数的 NameError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7008083/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com