by simonpantzare · 14y ago · 0 comments
# incomplete partial: add(?, 2)
>>> s2 = add.s(2)
# resolves the partial: add(8, 2)
>>> res = s2.delay(8)
>>> res.get()
10
Shouldn't it behave like functools.partial[2]? >>> import functools
>>> abc = lambda a, b, c: (a, b, c)
>>> bc = functools.partial(abc, "a")
>>> bc("b", "c")
('a', 'b', 'c')
1. http://docs.celeryproject.org/en/latest/getting-started/next...2. http://docs.python.org/library/functools.html#functools.part...
The reason is that I found that it better matches what you use them for in Celery, since they are used e.g. to forward results from the previous tasks to a callback. Often you have a signatures like: def blur_image(image, amount=1), where the partial is used like render_image.s(file) | blur_image.s()
functools.partial is usually used the other way; it's most common to create functools.partials where the first argument is satisfied.