コード例 #1
0
ファイル: canvas.py プロジェクト: tothegump/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 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
ファイル: canvas.py プロジェクト: YuelianINC/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.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
ファイル: canvas.py プロジェクト: tothegump/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
コード例 #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
ファイル: functional.py プロジェクト: sambrin/thorn
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
ファイル: canvas.py プロジェクト: rossdeane/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.subtask_type = "chain"
コード例 #12
0
ファイル: canvas.py プロジェクト: AdrianRibao/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.group", (), {"tasks": tasks}, options)
     self.tasks, self.subtask_type = tasks, "group"
コード例 #13
0
ファイル: canvas.py プロジェクト: mozilla/firefox-flicks
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