示例#1
0
 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)
示例#2
0
 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'
示例#3
0
文件: canvas.py 项目: wido/celery
 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)
示例#4
0
 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
示例#5
0
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
示例#6
0
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
示例#7
0
文件: canvas.py 项目: aliscott/celery
def _maybe_group(tasks):
    if isinstance(tasks, group):
        tasks = list(tasks.tasks)
    else:
        tasks = regen(tasks if is_list(tasks) else tasks)
    return tasks
示例#8
0
 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"
示例#9
0
 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"
示例#10
0
 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'
示例#11
0
 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"
示例#12
0
 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"
示例#13
0
def _maybe_group(tasks):
    if isinstance(tasks, group):
        tasks = list(tasks.tasks)
    else:
        tasks = regen(tasks if is_list(tasks) else tasks)
    return tasks
示例#14
0
文件: canvas.py 项目: xeneta/celery
 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