セロリで次のコードを実行すると、タスクは成功しました:
ystd = date.yesterday()
task_obj = TelecomTask()
tsk1 = chain([task_obj.craw_allkeyword.s(1, ystd),
task_obj.save_allkeyword_date_pv.s(task_obj),
task_obj.save_allkeyword_date_pv_pct.s(task_obj)])
tsk_grp1 = chain(tsk1, group(task_obj.cal_allkeyword_week_pv.s(task_obj), task_obj.cal_allkeyword_month_pv.s(task_obj)))
task_group_array = []
task_group_array.append(tsk_grp1)
header = group(task_group_array)
callback = task_obj.set_telecom_allkeyword_data_date.si(task_obj,ystd)
chain(header,callback)()
そしてそのような結果:
[2015-05-27 12:00:44,212: INFO/MainProcess] Received task: task.telecom.craw_allkeyword[56724aa6-28c2-4c0d-aee7-5bb04c2f8714]
[2015-05-27 12:00:44,292: INFO/MainProcess] Received task: task.telecom.save_allkeyword_date_pv[a7acf3d0-896c-4da0-820d-2e4386193e40]
[2015-05-27 12:00:44,357: INFO/MainProcess] Received task: task.telecom.save_allkeyword_date_pv_pct[1d59c7cd-bd44-482c-86e2-a9d64f270b9c]
[2015-05-27 12:00:44,376: INFO/MainProcess] Task task.telecom.craw_allkeyword[56724aa6-28c2-4c0d-aee7-5bb04c2f8714] succeeded in 0.156798792072s: <utn.spider.ubd.crawler.AllKeywordResult object at 0x37e4a90>
[2015-05-27 12:00:44,381: INFO/MainProcess] Task task.telecom.save_allkeyword_date_pv[a7acf3d0-896c-4da0-820d-2e4386193e40] succeeded in 0.0782759757712s: <utn.spider.ubd.crawler.AllKeywordResult object at 0x37389d0>
[2015-05-27 12:00:44,654: INFO/MainProcess] Received task: task.telecom.cal_allkeyword_week_pv[d1381348-6c45-4716-b409-c0a73fa6fca1]
[2015-05-27 12:00:44,656: INFO/MainProcess] Received task: task.telecom.cal_allkeyword_month_pv[a20b2f41-8272-49db-8ee5-9fb8eb6385ce]
[2015-05-27 12:00:44,664: WARNING/Worker-3] <utn.spider.ubd.crawler.AllKeywordResult object at 0x37f23d0>
[2015-05-27 12:00:44,664: WARNING/Worker-3] <utn.spider.ubd.task.TelecomTask object at 0x38a0e90>
[2015-05-27 12:00:44,670: INFO/MainProcess] Received task: celery.chord_unlock[243fa4d8-32d1-4e37-808c-bbd10e4bb469] eta:[2015-05-27 12:00:45.657176+08:00]
[2015-05-27 12:00:44,742: INFO/MainProcess] Task task.telecom.save_allkeyword_date_pv_pct[1d59c7cd-bd44-482c-86e2-a9d64f270b9c] succeeded in 0.381001189817s: <utn.spider.ubd.crawler.AllKeywordResult object at 0x3739b50>
[2015-05-27 12:00:45,427: INFO/MainProcess] Task task.telecom.cal_allkeyword_week_pv[d1381348-6c45-4716-b409-c0a73fa6fca1] succeeded in 0.767911130097s: 'SUCCESS'
[2015-05-27 12:00:45,428: INFO/MainProcess] Task task.telecom.cal_allkeyword_month_pv[a20b2f41-8272-49db-8ee5-9fb8eb6385ce] succeeded in 0.764119229745s: 'SUCCESS'
[2015-05-27 12:00:46,032: INFO/MainProcess] Received task: task.telecom.set_telecom_allkeyword_data_date[256518f1-28d2-4450-aca3-8f9930e7e531]
[2015-05-27 12:00:46,034: INFO/MainProcess] Task celery.chord_unlock[243fa4d8-32d1-4e37-808c-bbd10e4bb469] succeeded in 0.0661644558422s: None
[2015-05-27 12:00:46,065: INFO/MainProcess] Task task.telecom.set_telecom_allkeyword_data_date[256518f1-28d2-4450-aca3-8f9930e7e531] succeeded in 0.0305925509892s: None
しかし、チェーンをchordに変更すると、タスクは無限に再試行を続け、コールバックを実行しません。以下は私が変更したコードです:
chord(header,callback)()
そしてそのようなログ:
[2015-05-27 12:31:40,548: INFO/MainProcess] Task celery.chord_unlock[60b4e477-cca9-4124-972d-d557745a8ac8] retry: Retry in 1s
[2015-05-27 12:31:42,645: INFO/MainProcess] Received task: celery.chord_unlock[60b4e477-cca9-4124-972d-d557745a8ac8] eta:[2015-05-27 12:31:43.626496+08:00]
[2015-05-27 12:31:42,646: INFO/MainProcess] Task celery.chord_unlock[60b4e477-cca9-4124-972d-d557745a8ac8] retry: Retry in 1s
[2015-05-27 12:31:44,644: INFO/MainProcess] Received task: celery.chord_unlock[60b4e477-cca9-4124-972d-d557745a8ac8] eta:[2015-05-27 12:31:45.628012+08:00]
[2015-05-27 12:31:44,645: INFO/MainProcess] Task celery.chord_unlock[60b4e477-cca9-4124-972d-d557745a8ac8] retry: Retry in 1s
[2015-05-27 12:31:45,664: INFO/MainProcess] Received task: celery.chord_unlock[60b4e477-cca9-4124-972d-d557745a8ac8] eta:[2015-05-27 12:31:46.652379+08:00]
[2015-05-27 12:31:45,666: INFO/MainProcess] Task celery.chord_unlock[60b4e477-cca9-4124-972d-d557745a8ac8] retry: Retry in 1s
コードの何が問題なのですか?誰か助けて、ありがとう