当前位置: 首页>>代码示例>>Python>>正文


Python canvas.subtask函数代码示例

本文整理汇总了Python中celery.canvas.subtask函数的典型用法代码示例。如果您正苦于以下问题:Python subtask函数的具体用法?Python subtask怎么用?Python subtask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了subtask函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: unlock_chord

 def unlock_chord(setid, callback, interval=1, propagate=False,
         max_retries=None, result=None):
     result = _res.TaskSetResult(setid, map(_res.AsyncResult, result))
     j = result.join_native if result.supports_native_join else result.join
     if result.ready():
         subtask(callback).delay(j(propagate=propagate))
     else:
         unlock_chord.retry(countdown=interval, max_retries=max_retries)
开发者ID:ahalife,项目名称:celery,代码行数:8,代码来源:builtins.py

示例2: unlock_chord

 def unlock_chord(group_id, callback, interval=1, propagate=False,
         max_retries=None, result=None):
     AR = _res.AsyncResult
     result = _res.GroupResult(group_id, [AR(r) for r in result])
     j = result.join_native if result.supports_native_join else result.join
     if result.ready():
         subtask(callback).delay(j(propagate=propagate))
     else:
         unlock_chord.retry(countdown=interval, max_retries=max_retries)
开发者ID:spulec,项目名称:celery,代码行数:9,代码来源:builtins.py

示例3: run

 def run(self, tasks, result, setid):
     app = self.app
     result = from_serializable(result)
     if self.request.is_eager or app.conf.CELERY_ALWAYS_EAGER:
         return app.TaskSetResult(result.id,
                 [subtask(task).apply(taskset_id=setid)
                     for task in tasks])
     with app.default_producer() as pub:
         [subtask(task).apply_async(taskset_id=setid, publisher=pub)
                 for task in tasks]
     parent = get_current_task()
     if parent:
         parent.request.children.append(result)
     return result
开发者ID:ahalife,项目名称:celery,代码行数:14,代码来源:builtins.py

示例4: run

 def run(self, tasks, result, group_id):
     app = self.app
     result = from_serializable(result)
     if self.request.is_eager or app.conf.CELERY_ALWAYS_EAGER:
         return app.GroupResult(result.id,
                 [subtask(task).apply(group_id=group_id)
                     for task in tasks])
     with app.default_producer() as pub:
         [subtask(task).apply_async(group_id=group_id, publisher=pub,
                                    add_to_parent=False)
                 for task in tasks]
     parent = get_current_worker_task()
     if parent:
         parent.request.children.append(result)
     return result
开发者ID:rwillmer,项目名称:celery,代码行数:15,代码来源:builtins.py

示例5: subtask

    def subtask(self, *args, **kwargs):
        """Returns :class:`~celery.subtask` object for
        this task, wrapping arguments and execution options
        for a single task invocation."""
        from celery.canvas import subtask

        return subtask(self, *args, **kwargs)
开发者ID:robftz,项目名称:celery,代码行数:7,代码来源:task.py

示例6: unlock_chord

    def unlock_chord(group_id, callback, interval=None, propagate=True,
                     max_retries=None, result=None,
                     Result=app.AsyncResult, GroupResult=app.GroupResult,
                     from_serializable=from_serializable):
        if interval is None:
            interval = unlock_chord.default_retry_delay
        deps = GroupResult(
            group_id,
            [from_serializable(r, Result=Result) for r in result],
        )
        j = deps.join_native if deps.supports_native_join else deps.join

        if deps.ready():
            callback = subtask(callback)
            try:
                ret = j(propagate=propagate)
            except Exception as exc:
                culprit = next(deps._failed_join_report())

                app._tasks[callback.task].backend.fail_from_current_stack(
                    callback.id, exc=ChordError('Dependency %s raised %r' % (
                        culprit.id, exc)),
                )
            else:
                callback.delay(ret)
        else:
            return unlock_chord.retry(countdown=interval,
                                      max_retries=max_retries)
开发者ID:DotNetWebs,项目名称:celery,代码行数:28,代码来源:builtins.py

示例7: unlock_chord

    def unlock_chord(group_id, callback, interval=None, propagate=None,
                     max_retries=None, result=None,
                     Result=app.AsyncResult, GroupResult=app.GroupResult,
                     from_serializable=from_serializable):
        # if propagate is disabled exceptions raised by chord tasks
        # will be sent as part of the result list to the chord callback.
        # Since 3.1 propagate will be enabled by default, and instead
        # the chord callback changes state to FAILURE with the
        # exception set to ChordError.
        propagate = default_propagate if propagate is None else propagate

        # check if the task group is ready, and if so apply the callback.
        deps = GroupResult(
            group_id,
            [from_serializable(r, Result=Result) for r in result],
        )
        j = deps.join_native if deps.supports_native_join else deps.join

        if deps.ready():
            callback = subtask(callback)
            try:
                ret = j(propagate=propagate)
            except Exception, exc:
                culprit = deps._failed_join_report().next()
                app._tasks[callback.task].backend.fail_from_current_stack(
                    callback.id, exc=ChordError('Dependency %s raised %r' % (
                        culprit.id, exc)),
                )
            else:
                try:
                    callback.delay(ret)
                except Exception, exc:
                    app._tasks[callback.task].backend.fail_from_current_stack(
                        callback.id,
                        exc=ChordError('Call callback error: %r' % (exc, )))
开发者ID:mozilla,项目名称:FlightDeck-lib,代码行数:35,代码来源:builtins.py

示例8: run

 def run(self, tasks, result):
     app = self.app
     result = from_serializable(result)
     if self.request.is_eager or app.conf.CELERY_ALWAYS_EAGER:
         return app.TaskSetResult(result.id,
                 [subtask(task).apply(taskset_id=self.request.taskset)
                     for task in tasks])
     with app.pool.acquire(block=True) as conn:
         with app.amqp.TaskPublisher(conn) as publisher:
             [subtask(task).apply_async(
                             taskset_id=self.request.taskset,
                             publisher=publisher)
                     for task in tasks]
     parent = get_current_task()
     if parent:
         parent.request.children.append(result)
     return result
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:17,代码来源:builtins.py

示例9: run

 def run(self, tasks, result, group_id, partial_args):
     app = self.app
     result = from_serializable(result, app)
     # any partial args are added to all tasks in the group
     taskit = (subtask(task).clone(partial_args) for i, task in enumerate(tasks))
     if self.request.is_eager or app.conf.CELERY_ALWAYS_EAGER:
         return app.GroupResult(result.id, [stask.apply(group_id=group_id) for stask in taskit])
     with app.producer_or_acquire() as pub:
         [stask.apply_async(group_id=group_id, publisher=pub, add_to_parent=False) for stask in taskit]
     parent = get_current_worker_task()
     if parent:
         parent.request.children.append(result)
     return result
开发者ID:uceo,项目名称:uceo-2015,代码行数:13,代码来源:builtins.py

示例10: unlock_chord

    def unlock_chord(group_id, callback, interval=None, propagate=None,
                     max_retries=None, result=None,
                     Result=app.AsyncResult, GroupResult=app.GroupResult,
                     from_serializable=from_serializable):
        # if propagate is disabled exceptions raised by chord tasks
        # will be sent as part of the result list to the chord callback.
        # Since 3.1 propagate will be enabled by default, and instead
        # the chord callback changes state to FAILURE with the
        # exception set to ChordError.
        propagate = default_propagate if propagate is None else propagate
        if interval is None:
            interval = unlock_chord.default_retry_delay

        # check if the task group is ready, and if so apply the callback.
        deps = GroupResult(
            group_id,
            [from_serializable(r, app=app) for r in result],
        )
        j = deps.join_native if deps.supports_native_join else deps.join

        if deps.ready():
            callback = subtask(callback)
            try:
                ret = j(propagate=propagate)
            except Exception as exc:
                try:
                    culprit = next(deps._failed_join_report())
                    reason = 'Dependency {0.id} raised {1!r}'.format(
                        culprit, exc,
                    )
                except StopIteration:
                    reason = repr(exc)

                app._tasks[callback.task].backend.fail_from_current_stack(
                    callback.id, exc=ChordError(reason),
                )
            else:
                try:
                    callback.delay(ret)
                except Exception as exc:
                    app._tasks[callback.task].backend.fail_from_current_stack(
                        callback.id,
                        exc=ChordError('Callback error: {0!r}'.format(exc)),
                    )
        else:
            return unlock_chord.retry(countdown=interval,
                                      max_retries=max_retries)
开发者ID:lolo121,项目名称:celery,代码行数:47,代码来源:builtins.py

示例11: xmap

 def xmap(task, it):
     task = subtask(task).type
     return [task(item) for item in it]
开发者ID:lolo121,项目名称:celery,代码行数:3,代码来源:builtins.py

示例12: xstarmap

 def xstarmap(task, it):
     task = subtask(task).type
     return list(starmap(task, it))
开发者ID:ahalife,项目名称:celery,代码行数:3,代码来源:builtins.py

示例13: xmap

 def xmap(task, it):
     task = subtask(task).type
     return list(map(task, it))
开发者ID:ahalife,项目名称:celery,代码行数:3,代码来源:builtins.py

示例14: xmap

 def xmap(task, it):
     task = subtask(task).type
     return [task(value) for value in it]
开发者ID:uceo,项目名称:uceo-2015,代码行数:3,代码来源:builtins.py

示例15: test_link_error

 def test_link_error(self):
     x = subtask(SIG)
     x.link_error(SIG)
     x.link_error(SIG)
     self.assertIn(SIG, x.options["link_error"])
     self.assertEqual(len(x.options["link_error"]), 1)
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:6,代码来源:test_canvas.py


注:本文中的celery.canvas.subtask函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。