當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。