Celery v0.8.1 (stable) documentation
Utility functions
Split an iterator into chunks with n elements each.
Examples
# n == 2 >>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 2) >>> list(x) [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10]]
# n == 3 >>> x = chunks(iter([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), 3) >>> list(x) [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10]]
With a function, and a list of keyword arguments, returns arguments in the list which the function takes.
Parameters: |
|
---|
Examples
>>> def foo(self, x, y, logfile=None, loglevel=None): ... return x * y >>> fun_takes_kwargs(foo, ["logfile", "loglevel", "task_id"]) ["logfile", "loglevel"]>>> def foo(self, x, y, **kwargs): >>> fun_takes_kwargs(foo, ["logfile", "loglevel", "task_id"]) ["logfile", "loglevel", "task_id"]
Generate a unique id, having - hopefully - a very small chance of collission.
For now this is provided by uuid.uuid4().
Retry the function over and over until max retries is exceeded.
For each retry we sleep a for a while before we try again, this interval is increased for every retry until the max seconds is reached.
Parameters: |
|
---|