Beispiel #1
0
def exists(task_id):
    """True if the task exists."""
    try:
        db.task_get(task_id)
        return True
    except db.TaskNotFound:
        return False
Beispiel #2
0
def exists(task_id):
    """True if the task exists."""
    try:
        db.task_get(task_id)
        return True
    except db.TaskNotFound:
        return False
Beispiel #3
0
def run(task_id):
    """Runs the task with task id.

    Underlying method will receive two kwargs:
        task_id = id of the current task for updating
        progress = last progress passed to task_update"""
    task = db.task_get(task_id)
    if task['is_member']:
        method = getattr(task['args'][0], task['method'])
    else:
        method = task['method']
    db.task_start(task_id)
    return method(task_id=task['id'], progress=task['progress'],
                  *task['args'], **task['kwargs'])
Beispiel #4
0
def run(task_id):
    """Runs the task with task id.

    Underlying method will receive two kwargs:
        task_id = id of the current task for updating
        progress = last progress passed to task_update"""
    task = db.task_get(task_id)
    if task['is_member']:
        method = getattr(task['args'][0], task['method'])
    else:
        method = task['method']
    db.task_start(task_id)
    return method(task_id=task['id'],
                  progress=task['progress'],
                  *task['args'],
                  **task['kwargs'])
Beispiel #5
0
def is_complete(task_id):
    """Completed if the task is done."""
    try:
        return db.task_get(task_id)['completed_at'] is not None
    except db.TaskNotFound:
        return False
Beispiel #6
0
def is_active(task_id):
    """True if the task is active."""
    try:
        return db.task_get(task_id)['is_active']
    except db.TaskNotFound:
        return False
Beispiel #7
0
def get(task_id):
    """Get task from id."""
    return db.task_get(task_id)
Beispiel #8
0
def is_complete(task_id):
    """Completed if the task is done."""
    try:
        return db.task_get(task_id)['completed_at'] is not None
    except db.TaskNotFound:
        return False
Beispiel #9
0
def is_active(task_id):
    """True if the task is active."""
    try:
        return db.task_get(task_id)['is_active']
    except db.TaskNotFound:
        return False
Beispiel #10
0
def get(task_id):
    """Get task from id."""
    return db.task_get(task_id)