Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

AttributeError: SMTP instance has no attribute 'sock'

After some minutes starting the server (tried with gunicorn, uwsgi, mod_wsgi) I get this error. Why does it work normally but stop working after some time?

Traceback (most recent call last):
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 131, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/handlers/wsgi.py", line 255, in __call__
    response = self.get_response(request)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/handlers/base.py", line 178, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/handlers/base.py", line 212, in handle_uncaught_exception
    'request': request
  File "/usr/lib/python2.7/logging/__init__.py", line 1166, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib/python2.7/logging/__init__.py", line 1258, in _log
    self.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1268, in handle
    self.callHandlers(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 1308, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python2.7/logging/__init__.py", line 748, in handle
    self.emit(record)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/utils/log.py", line 113, in emit
    mail.mail_admins(subject, message, fail_silently=True, html_message=html_message)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/__init__.py", line 98, in mail_admins
    mail.send(fail_silently=fail_silently)
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/message.py", line 255, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/backends/smtp.py", line 99, in send_messages
    self.close()
  File "/home/wiseguy/projects/venv/local/lib/python2.7/site-packages/Django-1.5-py2.7.egg/django/core/mail/backends/smtp.py", line 72, in close
    self.connection.close()
  File "/usr/lib/python2.7/smtplib.py", line 747, in close
    if self.sock:
AttributeError: SMTP instance has no attribute 'sock'