October 2018
Intermediate to advanced
332 pages
8h 9m
English
The first application of task signatures is functional programming style partials. Partials are functions, which originally take many arguments, but an operation is applied to the original function to return a new function, so the first n arguments are always the same. Consider the following example, where we have a multiply function that is not a task:
>>> new_multiply = multiply(2) >>> new_multiply(5) 10 # The first function is unaffected >>> multiply(2, 2) 4
This is a fictional API, but is very close to the Celery version:
>>> partial = multiply.s(4) >>> partial.delay(4)
The output in the worker window should show 16. Basically, we created a new function, saved to partial, that will always multiply its input by four.