celery.utils.functional
class celery.utils.functional.LRUCache(limit=None)
LRU Cache implementation using a doubly linked list to track access.
celery.utils.functional.is_list(l, scalars=(<class ‘_abcoll.Mapping’>, <type ‘basestring’>), iters=(<class ‘_abcoll.Iterable’>, ))
Return true if the object is iterable (but not if object is a mapping or string).
celery.utils.functional.maybe_list(l, scalars=(<class ‘_abcoll.Mapping’>, <type ‘basestring’>))[源代码]
Return list of one element if l is a scalar.
celery.utils.functional.memoize(maxsize=None, Cache=<class celery.utils.functional.LRUCache at 0xaf68c8c>)
class celery.utils.functional.mlazy(fun, \args, **kwargs*)
Memoized lazy evaluation.
evaluated
Set to to True after the object has been evaluated.
evaluate()
evaluated = False
celery.utils.functional.noop(\args, **kwargs*)[源代码]
No operation.
Takes any arguments/keyword arguments and does nothing.
celery.utils.functional.first(predicate, it)
Return the first element in iterable that predicate Gives a True value for.
If predicate is None it will return the first item that is not None.
celery.utils.functional.firstmethod(method)[源代码]
Return a function that with a list of instances, finds the first instance that gives a value for the given method.
The list can also contain lazy instances (.)
celery.utils.functional.chunks(it, n)[源代码]
Split an iterator into chunks with n elements each.
Examples
celery.utils.functional.padlist(container, size, default=None)
Pad list with default elements.
Examples:
celery.utils.functional.mattrgetter(\attrs*)[源代码]
Like but return None on missing attributes instead of raising AttributeError.
celery.utils.functional.uniq(it)
Return all unique elements in it, preserving order.
celery.utils.functional.regen(it)[源代码]
Regen takes any iterable, and if the object is an generator it will cache the evaluated list on first access, so that the generator can be “consumed” multiple times.
celery.utils.functional.dictfilter(d=None, \*kw*)
Remove all keys from dict d whose value is None
class celery.utils.functional.lazy(fun, \args, **kwargs*)
Holds lazy evaluation.
Evaluated when called or if the method is called. The function is re-evaluated on every call.
Overloaded operations that will evaluate the promise:
__str__(), __repr__(), __cmp__().
Evaluates if the value is a lazy instance.