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


Python control.inspect方法代码示例

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


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

示例1: celery_info

# 需要导入模块: from celery.task import control [as 别名]
# 或者: from celery.task.control import inspect [as 别名]
def celery_info():
    from celery.task.control import inspect
    i = inspect()
    info = []
    active = i.active()
    if not active:
        return [('Error', 'Could not inspect Celery: it may be down.')]
    for worker, tasks in list(active.items()):
        if tasks:
            taskstr = '; '.join("%s(*%s, **%s)" % (t['name'], t['args'], t['kwargs'])
                       for t in tasks)
        else:
            taskstr = 'None'

        info.append((worker + ' active', taskstr))

    for worker, tasks in list(i.scheduled().items()):
        info.append((worker + ' scheduled', len(tasks)))

    info.sort()
    return info 
开发者ID:sfu-fas,项目名称:coursys,代码行数:23,代码来源:panel.py

示例2: get_celery_worker_status

# 需要导入模块: from celery.task import control [as 别名]
# 或者: from celery.task.control import inspect [as 别名]
def get_celery_worker_status():
    """
    Detects if working
    """
    # from
    # http://stackoverflow.com/questions/8506914/detect-whether-celery-is-available-running
    ERROR_KEY = "ERROR"
    try:
        from celery.task.control import inspect
        insp = inspect()
        d = insp.stats()
        if not d:
            d = {ERROR_KEY: 'No running Celery workers were found.'}
    except IOError as e:
        from errno import errorcode
        msg = "Error connecting to the backend: " + str(e)
        if len(e.args) > 0 and errorcode.get(e.args[0]) == 'ECONNREFUSED':
            msg += ' Check that the RabbitMQ server is running.'
        d = {ERROR_KEY: msg}
    except ImportError as e:
        d = {ERROR_KEY: str(e)}
    return d 
开发者ID:seanbell,项目名称:opensurfaces,代码行数:24,代码来源:utils.py

示例3: get_celery_worker_status

# 需要导入模块: from celery.task import control [as 别名]
# 或者: from celery.task.control import inspect [as 别名]
def get_celery_worker_status():
    ERROR_KEY = "ERROR"
    try:
        from celery.task.control import inspect
        insp = inspect()
        d = insp.stats()
        if not d:
            d = {ERROR_KEY: 'No running Celery workers were found.'}
    except IOError as e:
        from errno import errorcode
        msg = "Error connecting to the backend: " + str(e)
        if len(e.args) > 0 and errorcode.get(e.args[0]) == 'ECONNREFUSED':
            msg += ' Check that the RabbitMQ server is running.'
        d = {ERROR_KEY: msg}
    except ImportError as e:
        d = {ERROR_KEY: str(e)}
    return d 
开发者ID:neon-jungle,项目名称:wagtail-linkchecker,代码行数:19,代码来源:scanner.py

示例4: task_stats

# 需要导入模块: from celery.task import control [as 别名]
# 或者: from celery.task.control import inspect [as 别名]
def task_stats(request):
    celery_inspect = control.inspect()
    stats = celery_inspect.stats()
    active = celery_inspect.active()
    scheduled = celery_inspect.scheduled()

    context = cornerwise_admin.each_context(request)
    context.update({"nodes": {node: {"tasks": nodestats["total"],
                                     "active": active[node],
                                     "scheduled": scheduled[node],
                                     "up_since": uptime_to_date(int(nodestats["clock"]))}
                              for node, nodestats in (stats.items() if stats else [])},
                    "title": "Celery Stats"})

    return render(request, "admin/task_stats.djhtml", context) 
开发者ID:codeforboston,项目名称:cornerwise,代码行数:17,代码来源:admin_views.py

示例5: is_task_active

# 需要导入模块: from celery.task import control [as 别名]
# 或者: from celery.task.control import inspect [as 别名]
def is_task_active(fun, task_id, args):
    from celery.task.control import inspect

    if not args:
        args = "()"  # empty args

    i = inspect()
    active_tasks = i.active()
    for _, tasks in active_tasks.items():
        for task in tasks:
            if task.get("id") == task_id:
                continue
            if task.get("name") == fun and task.get("args") == str(args):
                return True
    return False 
开发者ID:Netflix,项目名称:lemur,代码行数:17,代码来源:celery.py

示例6: _worker_inspector

# 需要导入模块: from celery.task import control [as 别名]
# 或者: from celery.task.control import inspect [as 别名]
def _worker_inspector(task):
    global _inspector
    if _inspector is None:
        _inspector = inspect([task.request.hostname])

    return _inspector


# Get this list of currently revoked tasks for this worker 
开发者ID:girder,项目名称:girder_worker,代码行数:11,代码来源:utils.py

示例7: _is_update_in_progress

# 需要导入模块: from celery.task import control [as 别名]
# 或者: from celery.task.control import inspect [as 别名]
def _is_update_in_progress(cls, device_id):
        active = inspect().active()
        if not active:
            return False
        # check if there's any other running task before adding it
        for task_list in active.values():
            for task in task_list:
                if task['name'] == _TASK_NAME and str(device_id) in task['args']:
                    return True
        return False 
开发者ID:openwisp,项目名称:openwisp-controller,代码行数:12,代码来源:apps.py


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