django异常 KeyError 在<module 'threading' from '/usr/lib/python2.6/threading.pyc'>被忽略

0 投票
2 回答
4926 浏览
提问于 2025-04-16 22:10

最近,我在我的Django应用程序1.3中添加了一个日志记录机制,使用了以下设置:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'debug':{
            'level':'DEBUG',
            'class':'logging.FileHandler',
            'formatter': 'verbose',
            'filename': base('logs/app_log/developer.debug.log') if ENV ==1 else base('../../logs/app_log/developer.debug.log'),
        },
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
        'mz.debug': {
            'handlers': ['debug'],
            'level': 'DEBUG',
            'propagate': True,
        },
    }
}

这个设置在我的本地机器上运行得很好,但一旦我把它部署到服务器上,就出现了以下错误:

[Sun Jul 24 06:37:04 2011] [error] Exception KeyError: KeyError(-1218405744,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored

当我从服务器上移除日志设置时,它就正常工作了。我不知道我的设置中有什么导致服务器返回这样的错误,我该如何解决这个问题呢?非常感谢!

2 个回答

1

把你的Apache的mod_wsgi更新到3.3版本。我用的是Ubuntu 10.04,目前这个版本的包还没有更新。所以我选择了从源代码编译。在安装新版本3.3之前,一定要先禁用mod_wsgi。我当时没有这样做,结果我的Apache崩溃了,出现了以下错误:

seg fault or similar nasty error detected in the parent process
3

在谷歌上搜索

第一个结果

更新 mod_wsgi。

撰写回答