0

添加具有 ImageField 的表单后,我的网站上出现 MemoryError。该代码在我的开发服务器(OS X 10.7.4)上运行良好,但在我的暂存环境(CentOS)中失败。

对于看起来类似的问题,我有点不愿意使用此处提出的解决方案:Python ctypes MemoryError in fcgi process from PIL library。它改变了 python 本身——这似乎不利于长期维护。

我对如何调试这个有点一无所知...请帮助我治愈我的无知...

这是回溯:

Environment:


Request Method: POST
Request URL: http://myschoolzoneapp.eatechinc.com/debug/

Django Version: 1.4
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'accounts',
 'announcements',
 'api',
 'devices',
 'events',
 'menus',
 'organizations',
 'djangorestframework',
 'registration',
 'guardian',
 'south',
 'profiles')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'ischoolhub_project.middleware.ProcessMiddleware')


Traceback:
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/eatech/django/projects/ischoolhub-staging/ischoolhub_project/views.py" in debug
  22.         if form.is_valid():
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in is_valid
  124.         return self.is_bound and not bool(self.errors)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in _get_errors
  115.             self.full_clean()
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in full_clean
  270.         self._clean_fields()
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/forms.py" in _clean_fields
  285.                     value = field.clean(value, initial)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/fields.py" in clean
  535.         return super(FileField, self).clean(data)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/fields.py" in clean
  153.         value = self.to_python(value)
File "/tmp/egg-cache/Django-1.4-py2.7.egg/django/forms/fields.py" in to_python
  560.             import Image
File "/tmp/egg-cache/PIL-1.1.7-py2.7-linux-i686.egg/Image.py" in <module>
  45.     __import__("FixTk")
File "/usr/local/lib/python2.7/lib-tk/FixTk.py" in <module>
  15.     import ctypes
File "/usr/local/lib/python2.7/ctypes/__init__.py" in <module>
  555. _reset_cache()
File "/usr/local/lib/python2.7/ctypes/__init__.py" in _reset_cache
  279.     CFUNCTYPE(c_int)(lambda: None)

Exception Type: MemoryError at /debug/
Exception Value: 
4

1 回答 1

0

通过让 mod_wsgi 在用户 ID 下运行,使用https://bugzilla.redhat.com/show_bug.cgi?id=717404解决了这个问题。

于 2012-06-30T17:24:27.360 回答