traceback when encountering unhandled exception and trying to send email

83 views
Skip to first unread message

Etienne Le Sueur

unread,
Nov 20, 2014, 6:37:53 PM11/20/14
to django...@googlegroups.com
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?

Collin Anderson

unread,
Nov 21, 2014, 5:50:06 PM11/21/14
to django...@googlegroups.com
Hi,

Wow. Never seen that one before. I wonder if it's a threading issue / race condition.

I looks like there was an error, and then it ran into this error when trying to send an email about the original error.

What gunicorn worker type are you using?

You could try asking on the gunicorn list too.

You could try removing/commenting out the LOGGING config as that's mostly the defaults anyway.

Collin
Reply all
Reply to author
Forward
0 new messages