October 2018
Intermediate to advanced
332 pages
8h 9m
English
The chain function takes task signatures and passes the value of each result to the next value in the chain, returning one result, as follows:
>>> from celery import chain >>> sig = chain(multiply.s(10, 10), multiply.s(4), multiply.s(20)) # same as above >>> sig = (multiply.s(10, 10) | multiply.s(4) | multiply.s(20)) >>> result = sig.delay() >>> result.get() 8000
Chains and partials can be taken a bit further. Chains can be used to create new functions when using partials, and chains can be nested as follows:
# combining partials in chains >>> func = (multiply.s(10) | multiply.s(2)) >>> result = func.delay(16) >>> result.get() 320# chains can be nested >>> func = ( multiply.s(10) | multiply.s(2) | (multiply.s(4) | multiply.s(5)) ) ...