def __new__(cls, *tasks, **kwargs): # This forces `chain(X, Y, Z)` to work the same way as `X | Y | Z` if not kwargs and tasks: if len(tasks) != 1 or is_list(tasks[0]): tasks = tasks[0] if len(tasks) == 1 else tasks return reduce(operator.or_, tasks) return super(chain, cls).__new__(cls, *tasks, **kwargs)
def __init__(self, *tasks, **options): tasks = (regen(tasks[0]) if len(tasks) == 1 and is_list(tasks[0]) else tasks) Signature.__init__( self, 'celery.chain', (), {'tasks': tasks}, **options ) self.subtask_type = 'chain'
def __new__(cls, *tasks, **kwargs): # This forces `chain(X, Y, Z)` to work the same way as `X | Y | Z` if not kwargs and tasks: if len(tasks) == 1 and is_list(tasks[0]): # ensure chain(generator_expression) works. tasks = tasks[0] return reduce(operator.or_, tasks) return super(chain, cls).__new__(cls, *tasks, **kwargs)
def __init__(self, *tasks, **options): tasks = (regen(tasks[0]) if len(tasks) == 1 and is_list(tasks[0]) else tasks) Signature.__init__( self, 'celery.chain', (), {'tasks': tasks}, **options ) self._use_link = options.pop('use_link', None) self.subtask_type = 'chain' self._frozen = None
def traverse_subscribers(it, *args, **kwargs): stream = deque([it]) while stream: for node in maybe_list(stream.popleft()): if isinstance(node, string_types) and node.startswith('!'): node = symbol_by_name(node[1:]) if isinstance(node, Callable): node = node(*args, **kwargs) if is_list(node): stream.append(node) elif node: yield node
def _maybe_group(tasks): if isinstance(tasks, group): tasks = list(tasks.tasks) else: tasks = regen(tasks if is_list(tasks) else tasks) return tasks
def __init__(self, *tasks, **options): tasks = regen( tasks[0] if len(tasks) == 1 and is_list(tasks[0]) else tasks) Signature.__init__(self, "celery.group", (), {"tasks": tasks}, options) self.tasks, self.subtask_type = tasks, "group"
def __init__(self, *tasks, **options): tasks = tasks[0] if len(tasks) == 1 and is_list(tasks[0]) else tasks Signature.__init__(self, "celery.chain", (), {"tasks": tasks}, options) self.tasks = tasks self.subtask_type = "chain"
def __init__(self, *tasks, **options): tasks = (regen(tasks[0]) if len(tasks) == 1 and is_list(tasks[0]) else tasks) Signature.__init__(self, 'celery.chain', (), {'tasks': tasks}, **options) self.subtask_type = 'chain'
def __init__(self, *tasks, **options): tasks = regen(tasks[0]) if len(tasks) == 1 and is_list(tasks[0]) else tasks Signature.__init__(self, "celery.chain", (), {"tasks": tasks}, **options) self.subtask_type = "chain"
def __init__(self, *tasks, **options): tasks = regen(tasks[0] if len(tasks) == 1 and is_list(tasks[0]) else tasks) Signature.__init__(self, "celery.group", (), {"tasks": tasks}, options) self.tasks, self.subtask_type = tasks, "group"
def __init__(self, *tasks, **options): tasks = regen(tasks[0]) if len(tasks) == 1 and is_list(tasks[0]) else tasks Signature.__init__(self, "celery.chain", (), {"tasks": tasks}, **options) self._use_link = options.pop("use_link", None) self.subtask_type = "chain" self._frozen = None