我今天刚升级到Mac OSX 10.10.5,现在每次尝试使用djrill Django应用程序在GAE本地发送电子邮件时,我都会收到ConnectionError。
异常类型:ConnectionError 异常值:('连接已中止。',错误(22,'无效参数'))
我在10.10.5之前收到此错误,但在views.py的顶部包含以下代码作为解决方法。
import imp
import os.path
from google.appengine.tools.devappserver2.python import sandbox
sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
# Use the system socket.
psocket = os.path.join(os.path.dirname(os.__file__), 'socket.py')
imp.load_source('socket', psocket)
但是现在如果我在升级到10.10.5之后尝试执行以下代码块,我会遇到错误。
msg = EmailMultiAlternatives(
to=['user@domain.com'],
subject='TEST',
from_email='Admin <admin@projectname.appspotmail.com>',
)
msg.template_name = "template-name"
msg.send()
这是完整的追溯:
Request Method: GET
Request URL: http://localhost:16080/
Django Version: 1.4.13
Python Version: 2.7.10
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'<projectapp>',
'djrill')
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')
Traceback:
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.4/django/core/handlers/base.py" in get_response
109. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/<username>/<projectname>/order_manager/views.py" in _decorated
53. return view_func(request)
File "/Users/<username>/<projectname>/order_manager/views.py" in select_job
102. msg.send()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/django-1.4/django/core/mail/message.py" in send
248. return self.get_connection(fail_silently).send_messages([self])
File "/Users/<username>/<projectname>/djrill/mail/backends/djrill.py" in send_messages
68. sent = self._send(message)
File "/Users/<username>/<projectname>/djrill/mail/backends/djrill.py" in _send
107. response = requests.post(api_url, data=json.dumps(api_params, cls=JSONDateUTCEncoder))
File "/Users/<username>/<projectname>/requests/api.py" in post
109. return request('post', url, data=data, json=json, **kwargs)
File "/Users/<username>/<projectname>/requests/api.py" in request
50. response = session.request(method=method, url=url, **kwargs)
File "/Users/<username>/<projectname>/requests/sessions.py" in request
470. resp = self.send(prep, **send_kwargs)
File "/Users/<username>/<projectname>/requests/sessions.py" in send
578. r = adapter.send(request, **kwargs)
File "/Users/<username>/<projectname>/requests/adapters.py" in send
410. raise ConnectionError(err, request=request)
Exception Type: ConnectionError at /
Exception Value: ('Connection aborted.', error(22, 'Invalid argument'))
我很欣赏有关如何在升级到OSX 10.10.5之后再次使用djrill从我的GAE本地服务器发送电子邮件的建议。谢谢!
答案 0 :(得分:1)
我正在对一个看似无关的问题进行故障排除,偶然发现suitable workaround。我用version 2.3替换了我的App Engine项目中最新版本的python请求模块。