/opt/imh-python/lib/python3.9/site-packages/celery/app
NameSizeModeActions
__pycache__/-0755rm
amqp.py232360644editdlrm
annotations.py14450644editdlrm
autoretry.py25060644editdlrm
backends.py27460644editdlrm
base.py505840644editdlrm
builtins.py66730644editdlrm
control.py291710644editdlrm
defaults.py152660644editdlrm
events.py13260644editdlrm
log.py90670644editdlrm
registry.py20010644editdlrm
routes.py45270644editdlrm
task.py437940644editdlrm
trace.py275510644editdlrm
utils.py131600644editdlrm
__init__.py24300644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/celery/app/annotations.py (1445B)
"""Task Annotations. Annotations is a nice term for monkey-patching task classes in the configuration. This prepares and performs the annotations in the :setting:`task_annotations` setting. """ from celery.utils.functional import firstmethod, mlazy from celery.utils.imports import instantiate _first_match = firstmethod('annotate') _first_match_any = firstmethod('annotate_any') __all__ = ('MapAnnotation', 'prepare', 'resolve_all') class MapAnnotation(dict): """Annotation map: task_name => attributes.""" def annotate_any(self): try: return dict(self['*']) except KeyError: pass def annotate(self, task): try: return dict(self[task.name]) except KeyError: pass def prepare(annotations): """Expand the :setting:`task_annotations` setting.""" def expand_annotation(annotation): if isinstance(annotation, dict): return MapAnnotation(annotation) elif isinstance(annotation, str): return mlazy(instantiate, annotation) return annotation if annotations is None: return () elif not isinstance(annotations, (list, tuple)): annotations = (annotations,) return [expand_annotation(anno) for anno in annotations] def resolve_all(anno, task): """Resolve all pending annotations.""" return (x for x in (_first_match(anno, task), _first_match_any(anno)) if x)