2014-09-10 54 views
0

我正在django芹菜发送regsitration电子邮件,但芹菜不正常工作。Django芹菜电子邮件,芹菜不工作

我的错误是在芹菜

[2014-09-10 19:11:44,349: WARNING/MainProcess] [email protected] ready. 
[2014-09-10 19:13:38,586: INFO/MainProcess] Received task:  apps.kashmiri.tasks.SignUpTask[17ca2ae1-8c72-426c-babd-470a55ac19 
5] 
[2014-09-10 19:13:38,936: ERROR/Worker-1] Pool process <Worker(Worker-1, started)> error:  RuntimeError(RuntimeError("App reg 
stry isn't ready yet.",), <function model_unpickle at 0x034E4B30>, (('auth', 'User'), [],  <function simple_class_factory at 
x034E4AF0>)) 
Traceback (most recent call last): 
File "C:\Python27\lib\site-packages\billiard\pool.py", line 289, in run 
sys.exit(self.workloop(pid=pid)) 
File "C:\Python27\lib\site-packages\billiard\pool.py", line 350, in workloop 
req = wait_for_job() 
File "C:\Python27\lib\site-packages\billiard\pool.py", line 441, in receive 
ready, req = _receive(1.0) 
File "C:\Python27\lib\site-packages\billiard\pool.py", line 413, in _recv 
return True, loads(get_payload()) 
File "C:\Python27\lib\site-packages\billiard\common.py", line 77, in pickle_loads 
return load(BytesIO(s)) 
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 1450, in model_unpickle 
model = apps.get_model(*model_id) 
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 187, in get_model 
self.check_ready() 
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 119, in check_ready 
raise RuntimeError("App registry isn't ready yet.") 
RuntimeError: (RuntimeError("App registry isn't ready yet.",), <function model_unpickle at 0x034E4B30>, (('auth', 'User'), [ 
, <function simple_class_factory at 0x034E4AF0>)) 
[2014-09-10 19:13:39,233: ERROR/MainProcess] Process 'Worker-3' pid:7100 exited with 'signal -1' 

forms.py

from apps.kashmiri.tasks import SignUpTask 
SignUpTask.delay(user=user) 

celery.py

from __future__ import absolute_import 

import os 

from celery import Celery 
from django.conf import settings 


os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'kb.settings') 

app=Celery('kb') 

app.config_from_object('django.conf:settings') 
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) 

@app.task(bind= True) 
def debug_task(self): 
print('Request:{0!r}'.format(self.request)) 

tasks.py

from __future__ import absolute_import 
from celery.registry import tasks 
from celery.task import Task 
from celery.app import shared_task 
from django.utils.html import strip_tags 
from django.core.mail import EmailMultiAlternatives 
from django.template.loader import render_to_string 

class SignUpTask(Task): 
def run(self, user): 
    subject, from_email, to ='Welcome to Kashmiri Bhatta', '[email protected]', user.email 
    html_content = render_to_string('registration.html',{'user':user.email}) 
    text_content= strip_tags(html_content) 
    msg= EmailMultiAlternatives(subject, text_content, from_email, [to]) 
    msg.attach_alternative(html_content, "text/html") 
    msg.send() 

tasks.register(SignUpTask) 

当IM使用>>芹菜-A凸出工人-l信息

错误RuntimeError:(RuntimeError( “应用程序的注册表还没有准备好”,) 请解决它帮助..

+0

你使用的是'django 1.7'吗? – ChillarAnand 2014-09-10 15:39:03

+0

我使用当前版本 – 2014-09-11 05:27:44

回答

1

此问题仅在Django 1.7发生。它在github上报告并被修复为recenlty。升级到最新版本的芹菜。它应该解决问题

pip install celery --upgrade