Celery chain execution sequence error?

We have three time-consuming tasks that need to be executed sequentially, and the result of the previous task is passed as a parameter to the next task.

it just so happens that celery"s chain can support this requirement, so I wrote:

chain(task1.s({"a":1}), task2.s(), task.s())
chain.apply_async()

but in fact, at run time, the order in which the three tasks are executed is task1--task3--task2

I am really confused. I can"t thank you enough for your answer.

I run a web server by tornado, and it woke up the tasks by chain.

logging:
2018-07-23 18:34:12816tid:140228657469056 DEBUG: chain: fetch ({}) | callback () | convert () | format ()

the other tasks run in celery

logging:
[2018-07-23 1834 Received task: fetch [045acf81-274b-457c-8bb5-6d0248264b76]
[2018-07-23 1834 7dfee5786695 17786: INFO/MainProcess] Received task: format [103b4ffa-57db-4b04-a745-7dfee5786695]
[2018-07-23 18leman 34 227: INFO/MainProcess] Received task: convert [81ddbaf9-37b3-406a-b608-a05affa97f45]
[2018-07-23 18shuff34 045acf81 20442: INFO/MainProcess] Received task: callback [ B1ea7c70-db45-4501-9859-7ad22532c38a]

Mar.30,2021

work_flow = chain(task1.s({'a':1}), task2.s(), task.s())
work_flow()

there is no need to call apply_async, to take a closer look at the document ide/canvas.html?highlight=chain-sharpchains" rel=" nofollow noreferrer "> http://docs.celeryproject.org.


it turns out that the version of Celery is different between the two machines. After changing the same version, it runs normally

.
Menu