(worker, task_state)
Prints celery tasks that have been received by the given worker that are in the
    given state.

    Examples:
    print_tasks('celery@hqcelery0.internal-va.commcarehq.org_main', 'active')
    print_tasks('celery@hqcelery1.internal-va.commcarehq.org_sms_queue', 'reserved')
Prints celery tasks that have been received by the given worker that are in the
    given state.
Prints celery tasks that have been received by the given worker that are in the given state .
def print_tasks(worker, task_state):
    """
    Prints celery tasks that have been received by the given worker that are in the
    given state.

    Examples:
    print_tasks('celery@hqcelery0.internal-va.commcarehq.org_main', 'active')
    print_tasks('celery@hqcelery1.internal-va.commcarehq.org_sms_queue', 'reserved')
    """
    _validate_task_state(task_state)

    app = Celery()
    app.config_from_object(settings)
    inspect = app.control.inspect([worker])
    fcn = getattr(inspect, task_state)
    result = fcn()
    if not result:
        print("Worker does not appear to be online. Check worker name, and that it is running.")
        return

    tasks = result[worker]

    if not tasks:
        print('(none)')
        return

    if task_state == 'revoked':
        for task_id in tasks:
            print(task_id)
        return

    tasks = _get_task_info_fcn(task_state)(tasks)

    for task_info in tasks:
        if task_info.time_start:
            print(task_info.id, task_info.time_start, task_info.name)
        else:
            print(task_info.id, task_info.name)
def print_tasks ( worker , task_state ) : _validate_task_state ( task_state ) app = Celery ( ) app . config_from_object ( settings ) inspect = app . control . inspect ( [ worker ] ) fcn = getattr ( inspect , task_state ) result = fcn ( ) if not result : print ( "Worker does not appear to be online. Check worker name, and that it is running." ) return tasks = result [ worker ] if not tasks : print ( '(none)' ) return if task_state == 'revoked' : for task_id in tasks : print ( task_id ) return tasks = _get_task_info_fcn ( task_state ) ( tasks ) for task_info in tasks : if task_info . time_start : print ( task_info . id , task_info . time_start , task_info . name ) else : print ( task_info . id , task_info . name )