0
我不明白爲什麼我的任務被認爲是在所有的子任務完成之前完成。芹菜 - 任務成功之前它的子任務
tasks.scan_user.delay(1)
CODE:
@task()
def scan_chunk(ids):
occs = Occurence.objects.filter(product_id__in=ids)
result = scan_occurences_dummy_pool((x.id,x.url,x.xpath) for x in occs)
return result
@task()
def scan_user(id):
chunks = generate_chunks_from_user(id)
ch = chain(scan_chunk.si([x.id for x in chunk]) for chunk in chunks)
return ch()
這是芹菜輸出,你可以看到,在scan_user
成功的所有scan_chunks
完成之前,這是一個問題,因爲我想scan_user
給我們另一個chain
。
[2017-02-09 14:27:03,493: INFO/MainProcess] Received task: engineapp.tasks.scan_user[ed358a98-a685-4002-baac-993fdc7b64cf]
[2017-02-09 14:27:05,721: INFO/MainProcess] Received task: engineapp.tasks.scan_chunk[35b74e01-f9fa-471f-8c20-ecbf99a89201]
[2017-02-09 14:27:06,740: INFO/MainProcess] Task engineapp.tasks.scan_user[ed358a98-a685-4002-baac-993fdc7b64cf] succeeded in 3.24300003052s: <AsyncResult: 442f9373-d983-4696-a42a-ba42a8ce7761>
[2017-02-09 14:27:22,178: INFO/MainProcess] Received task: engineapp.tasks.scan_chunk[36a94ad4-3c9e-4f7d-a040-5c2a617a0d8f]
[2017-02-09 14:27:23,204: INFO/MainProcess] Task engineapp.tasks.scan_chunk[35b74e01-f9fa-471f-8c20-ecbf99a89201] succeeded in 17.4779999256s: [
我想創建另一個task
這將爲所有用戶按順序scan_user
運行,但我認爲這是不可能的,因爲它會在事實上平行。