Esempio n. 1
0
def exists(task_id):
    """True if the task exists."""
    try:
        db.task_get(task_id)
        return True
    except db.TaskNotFound:
        return False
Esempio n. 2
0
def exists(task_id):
    """True if the task exists."""
    try:
        db.task_get(task_id)
        return True
    except db.TaskNotFound:
        return False
Esempio n. 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'])
Esempio n. 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'])
Esempio n. 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
Esempio n. 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
Esempio n. 7
0
def get(task_id):
    """Get task from id."""
    return db.task_get(task_id)
Esempio n. 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
Esempio n. 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
Esempio n. 10
0
def get(task_id):
    """Get task from id."""
    return db.task_get(task_id)