我遇到了一個問題,我將任務放入隊列中,並且正在多次運行。 從芹菜日誌,我可以看到,同樣的工人正在運行的任務...芹菜/ Django單個任務正在多次運行
[2014-06-06 15:12:20,731: INFO/MainProcess] Received task: input.tasks.add_queue
[2014-06-06 15:12:20,750: INFO/Worker-2] starting runner..
[2014-06-06 15:12:20,759: INFO/Worker-2] collection started
[2014-06-06 15:13:32,828: INFO/Worker-2] collection complete
[2014-06-06 15:13:32,836: INFO/Worker-2] generation of steps complete
[2014-06-06 15:13:32,836: INFO/Worker-2] update created
[2014-06-06 15:13:33,655: INFO/Worker-2] email sent
[2014-06-06 15:13:33,656: INFO/Worker-2] update created
[2014-06-06 15:13:34,420: INFO/Worker-2] email sent
[2014-06-06 15:13:34,421: INFO/Worker-2] FINISH - Success
然而,當我認爲它是顯示每個步驟(5-6日誌行的應用程序的實際日誌? )。
我使用Django 1.6與RabbitMQ。放入隊列的方法是通過在函數上放置一個延遲。
此函數(任務裝飾中加入(然後調用其上運行的一類
有沒有人在解決它的最好方法任何想法
編輯:?作爲繼承人的要求代碼,
views.py
我認爲即時發送我的資料至t他通過排隊...
from input.tasks import add_queue_project
add_queue_project.delay(data)
tasks.py
from celery.decorators import task
@task()
def add_queue_project(data):
""" run project """
logger = logging_setup(app="project")
logger.info("starting project runner..")
f = project_runner(data)
f.main()
class project_runner():
""" main project runner """
def __init__(self,data):
self.data = data
self.logger = logging_setup(app="project")
def self.main(self):
.... Code
settings.py
THIRD_PARTY_APPS = (
'south', # Database migration helpers:
'crispy_forms', # Form layouts
'rest_framework',
'djcelery',
)
import djcelery
djcelery.setup_loader()
BROKER_HOST = "127.0.0.1"
BROKER_PORT = 5672 # default RabbitMQ listening port
BROKER_USER = "test"
BROKER_PASSWORD = "test"
BROKER_VHOST = "test"
CELERY_BACKEND = "amqp" # telling Celery to report the results back to RabbitMQ
CELERY_RESULT_DBURI = ""
CELERY_IMPORTS = ("input.tasks",)
celeryd
將L INE進出口運行是開始芹菜,
python2.7 manage.py celeryd -l info
感謝,
這些不是由celerybeat創建的工作,對不對? – JeffS
你是否在某些django信號處理程序中創建任務?如果是,那麼確保該信號不被多次調用。 –
請發佈您的代碼 – dm03514