Thursday, November 20, 2014

traceback when encountering unhandled exception and trying to send email

Hi Django users,

has anyone seen a similar traceback to this:

2014-11-20 14:48:14.190659500 gunicorn[20952]: ERROR: Error handling request
2014-11-20 14:48:14.190661500 Traceback (most recent call last):
2014-11-20 14:48:14.190661500   File "/build/toolchain/noarch/gunicorn-18.0/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 131, in handle_request
2014-11-20 14:48:14.190662500     respiter = self.wsgi(environ, resp.start_response)
2014-11-20 14:48:14.190662500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
2014-11-20 14:48:14.190674500     response = self.get_response(request)
2014-11-20 14:48:14.190674500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/core/handlers/base.py", line 194, in get_response
2014-11-20 14:48:14.190675500     response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
2014-11-20 14:48:14.190675500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
2014-11-20 14:48:14.190678500     'request': request
2014-11-20 14:48:14.190678500   File "/build/toolchain/lin32/python-2.7.5/lib/python2.7/logging/__init__.py", line 1175, in error
2014-11-20 14:48:14.190678500     self._log(ERROR, msg, args, **kwargs)
2014-11-20 14:48:14.190679500   File "/build/toolchain/lin32/python-2.7.5/lib/python2.7/logging/__init__.py", line 1268, in _log
2014-11-20 14:48:14.190682500     self.handle(record)
2014-11-20 14:48:14.190683500   File "/build/toolchain/lin32/python-2.7.5/lib/python2.7/logging/__init__.py", line 1278, in handle
2014-11-20 14:48:14.190683500     self.callHandlers(record)
2014-11-20 14:48:14.190683500   File "/build/toolchain/lin32/python-2.7.5/lib/python2.7/logging/__init__.py", line 1318, in callHandlers
2014-11-20 14:48:14.190684500     hdlr.handle(record)
2014-11-20 14:48:14.190686500   File "/build/toolchain/lin32/python-2.7.5/lib/python2.7/logging/__init__.py", line 749, in handle
2014-11-20 14:48:14.190686500     self.emit(record)
2014-11-20 14:48:14.190686500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/utils/log.py", line 122, in emit
2014-11-20 14:48:14.190687500     connection=self.connection())
2014-11-20 14:48:14.190687500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/utils/log.py", line 125, in connection
2014-11-20 14:48:14.190689500     return get_connection(backend=self.email_backend, fail_silently=True)
2014-11-20 14:48:14.190689500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/core/mail/__init__.py", line 29, in get_connection
2014-11-20 14:48:14.190690500     klass = import_by_path(backend or settings.EMAIL_BACKEND)
2014-11-20 14:48:14.190690500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/utils/module_loading.py", line 21, in import_by_path
2014-11-20 14:48:14.190700500     module = import_module(module_path)
2014-11-20 14:48:14.190700500   File "/build/toolchain/noarch/django-1.6.5/lib/python2.7/site-packages/django/utils/importlib.py", line 41, in import_module
2014-11-20 14:48:14.190701500     return sys.modules[name]
2014-11-20 14:48:14.190701500 KeyError: 'django.core.mail.backends.smtp'
2014-11-20 14:48:14.190861500 gunicorn[20952]: INFO: GET / HTTP/1.0 |  | - | 500 | 0s

Django clear tries to access a module that hasn't been loaded yet.

It is quite possibly a configuration error. Here are some sections from settings.py:

 97 MIDDLEWARE_CLASSES = (
 98     'django.middleware.common.CommonMiddleware',
 99     'django.contrib.sessions.middleware.SessionMiddleware',
100     'django.middleware.csrf.CsrfViewMiddleware',
101     'django.contrib.auth.middleware.AuthenticationMiddleware',
102     'django.contrib.messages.middleware.MessageMiddleware',
103 )


119 INSTALLED_APPS = (
120     'django.contrib.admin',
121     'django.contrib.auth',
122     'django.contrib.contenttypes',
123     'django.contrib.sessions',
124     'django.contrib.sites',
125     'django.contrib.messages',
126     'django.contrib.staticfiles',
127     'recommend',
128     'tastypie',
129     'gunicorn',
130 )

139 LOGGING = {
140     'version': 1,
141     'disable_existing_loggers': False,
142     'filters': {
143         'require_debug_false': {
144             '()': 'django.utils.log.RequireDebugFalse'
145         }
146     },
147     'formatters': {
148         'simple': {
149             'format': '%(levelname)s %(message)s',
150         },
151     },
152     'handlers': {
153         'mail_admins': {
154             'level': 'ERROR',
155             'filters': ['require_debug_false'],
156             'class': 'django.utils.log.AdminEmailHandler'
157         },
158         'console': {
159             'level': 'DEBUG',
160             'class': 'logging.StreamHandler',
161             'formatter': 'simple',
162         },
163     },
164     'loggers': {
165         'django.request': {
166             'handlers': ['mail_admins'],
167             'level': 'ERROR',
168             'propagate': True,
169         },
170         'django.db.backends': {
171             # set level to DEBUG if you want to see all SQL statements logged,
172             # along with profiling information
173             'handlers': ['console'],
174             'level': 'INFO',
175             'propagate': False,
176         },
177         'debug': {
178             'handlers': ['console'],
179             'level': 'DEBUG',
180             'propagate': False,
181         },
187     }
188 }

Can someone suggest how I would go about debugging this?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/157698a4-df5a-4490-aa6e-4985726cc9c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment