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


Python Signature.from_dict方法代码示例

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


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

示例1: setup_cluster

# 需要导入模块: from celery.canvas import Signature [as 别名]
# 或者: from celery.canvas.Signature import from_dict [as 别名]
def setup_cluster(task, *args, **kwargs):
    cluster = kwargs['cluster']

    if '_id' in cluster:
        task.taskflow.logger.info(
            'We are using an existing cluster: %s' % cluster['name'])
    else:
        task.taskflow.logger.info('We are creating an EC2 cluster.')
        task.logger.info('Cluster name %s' % cluster['name'])
        kwargs['machine'] = cluster.get('machine')
        profile = kwargs.get('profile')
        cluster = create_ec2_cluster(
            task, cluster, profile, kwargs['image_spec'])
        task.logger.info('Cluster started.')

    # Call any follow on task
    if 'next' in kwargs:
        kwargs['cluster'] = cluster
        next = Signature.from_dict(kwargs['next'])

        if next.task == 'celery.chain':
            # If we are dealing with a chain we want to update the arg and
            # kwargs passed into the chain.
            first_task = next.kwargs['tasks'][0]
            if first_task:
                if args:
                    first_task.args = tuple(args) + tuple(first_task.args)

                if kwargs:
                    first_task.kwargs = dict(first_task.kwargs, **kwargs)

        next.delay(*args, **kwargs)
开发者ID:Kitware,项目名称:cumulus,代码行数:34,代码来源:__init__.py

示例2: postcommit_after_request

# 需要导入模块: from celery.canvas import Signature [as 别名]
# 或者: from celery.canvas.Signature import from_dict [as 别名]
def postcommit_after_request(response, base_status_error_code=500):
    if response.status_code >= base_status_error_code:
        _local.postcommit_queue = OrderedDict()
        _local.postcommit_celery_queue = OrderedDict()
        return response
    try:
        if postcommit_queue():
            number_of_threads = 30  # one db connection per greenlet, let's share
            pool = Pool(number_of_threads)
            for func in postcommit_queue().values():
                pool.spawn(func)
            pool.join(timeout=5.0, raise_error=True)  # 5 second timeout and reraise exceptions

        if postcommit_celery_queue():
            if settings.USE_CELERY:
                for task_dict in postcommit_celery_queue().values():
                    task = Signature.from_dict(task_dict)
                    task.apply_async()
            else:
                for task in postcommit_celery_queue().values():
                    task()

    except AttributeError as ex:
        if not settings.DEBUG_MODE:
            logger.error('Post commit task queue not initialized: {}'.format(ex))
    return response
开发者ID:icereval,项目名称:osf.io,代码行数:28,代码来源:handlers.py

示例3: setup_cluster

# 需要导入模块: from celery.canvas import Signature [as 别名]
# 或者: from celery.canvas.Signature import from_dict [as 别名]
def setup_cluster(task, *args,**kwargs):
    cluster = kwargs['cluster']

    if '_id' in cluster:
        task.taskflow.logger.info('We are using an existing cluster: %s' % cluster['name'])
    else:
        task.taskflow.logger.info('We are creating an EC2 cluster.')
        task.logger.info('Cluster name %s' % cluster['name'])
        kwargs['machine'] = cluster.get('machine')
        ami = kwargs.get('ami')
        profile = kwargs.get('profile')
        cluster = create_ec2_cluster(task, cluster, profile, ami)
        task.logger.info('Cluster started.')

    # Call any follow on task
    if 'next' in kwargs:
        kwargs['cluster'] = cluster
        next = Signature.from_dict(kwargs['next'])
        next.delay(*args, **kwargs)
开发者ID:gongfuPanada,项目名称:HPCCloud,代码行数:21,代码来源:__init__.py

示例4: inner

# 需要导入模块: from celery.canvas import Signature [as 别名]
# 或者: from celery.canvas.Signature import from_dict [as 别名]
 def inner(*args, **kwargs):
     taskset = kwargs.pop("_taskset", None)
     rv = f(*args, **kwargs)
     if taskset is not None:
         done = False
         with transaction.atomic():
             taskset_id = taskset["taskset_id"]
             sync_row = TaskSetMeta.objects.select_for_update().filter(
                 id=taskset_id).all()
             if sync_row:
                 assert len(sync_row) == 1
                 sync_row = sync_row[0]
                 sync_row.count -= 1
                 sync_row.save()
                 if sync_row.count == 0:
                     logger.info("Finished taskset id %i" % taskset_id)
                     done = True
                 else:
                     logger.info("Taskset %i has %i tasks remaining" % (taskset_id, sync_row.count))
         if done:
             callback = Signature.from_dict(taskset["callback"])
             callback.apply_async()
     return rv
开发者ID:AnthonyMeaux,项目名称:treeherder,代码行数:25,代码来源:taskset.py

示例5: postcommit_celery_task_wrapper

# 需要导入模块: from celery.canvas import Signature [as 别名]
# 或者: from celery.canvas.Signature import from_dict [as 别名]
def postcommit_celery_task_wrapper(queue):
    # chain.apply calls the tasks synchronously without re-enqueuing each one
    # http://stackoverflow.com/questions/34177131/how-to-solve-python-celery-error-when-using-chain-encodeerrorruntimeerrormaxi?answertab=votes#tab-top
    # celery serialized signatures into dictionaries, so we need to deserialize here
    # https://sentry.cos.io/sentry/osf-iy/issues/289209/
    chain([Signature.from_dict(task_dict) for task_dict in queue.values()]).apply()
开发者ID:leb2dg,项目名称:osf.io,代码行数:8,代码来源:handlers.py


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