我正在尝试使用django celery发送电子邮件以安排任务。我正在调用一个电子邮件函数,该函数在单独调用时会起作用。但是,当从celery beats Scheduler调用时,出现错误:
提高ValueError(“未处理类型%s”%type(wire))ValueError: 未处理的类型
该应用程序称为仪表板。 在我的dashboard.tasks文件中:
from __future__ import absolute_import, unicode_literals
from celery import shared_task
from django_celery_beat.models import PeriodicTask, IntervalSchedule
from django.core.mail import send_mail
def sendConfirmEmail():
send_mail(
'Testing Hotmail',
'Here is the message.',
'someone@hotmail.com',
['someone@hotmail.com'],
fail_silently=False,
)
并在我的仪表板视图中:
@login_required(login_url='/login/')
def dashboard(request):
schedule, created = IntervalSchedule.objects.get_or_create(every=30,period=IntervalSchedule.SECONDS)
PeriodicTask.objects.create(interval=schedule,name="Send Email",task="dashboard.tasks.sendConfirmEmail",
)
return render(request,"dashboard/index.html",{})
我也在使用django-results-backend,rabbit和celery-beats 我得到的确切错误如下所示。
Traceback (most recent call last):
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\djcelery_email\tasks.py", line 41, in send_emails
conn.open()
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\django\core\mail\backends\smtp.py", line 63, in open
self.connection = self.connection_class(self.host, self.port, **connection_params)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\smtplib.py", line 251, in __init__
(code, msg) = self.connect(host, port)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\smtplib.py", line 336, in connect
self.sock = self._get_socket(host, port, self.timeout)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\smtplib.py", line 307, in _get_socket
self.source_address)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\green\socket.py", line 44, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 513, in getaddrinfo
qname, addrs = _getaddrinfo_lookup(host, family, flags)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 477, in _getaddrinfo_lookup
answer = resolve(host, qfamily, False)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 424, in resolve
return _proxy.query(name, rdtype, raise_on_no_answer=raises)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 382, in query
return end()
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 361, in end
raise result[1]
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 342, in step
a = fun(*args, **kwargs)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\dns\resolver.py", line 916, in query
source_port=source_port)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\greendns.py", line 807, in tcp
r = dns.message.from_wire(wire, keyring=q.keyring, request_mac=q.mac)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\dns\message.py", line 820, in from_wire
ignore_trailing)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\dns\message.py", line 601, in __init__
self.wire = dns.wiredata.maybe_wrap(wire)
File "c:\users\brandon\appdata\local\programs\python\python36-32\lib\site-packages\eventlet\support\dns\wiredata.py", line 103, in maybe_wrap
raise ValueError("unhandled type %s" % type(wire))
ValueError: unhandled type <class 'bytearray'>
有人知道我在做什么错吗?