def task_query(id): ret = {} # progress, result, error from async_ import AsyncManager task = AsyncManager.get_task(id) if task is not None: ret.update({'progress': getattr(task, 'progress', 0)}) if task.done(): if task.cancelled(): ret.update({'error': 'cancelled'}) elif task.exception() is not None: ret.update({'error': task.exception().args[0]}) else: ret.update({'result': task.result()}) else: ret.update({'error': 'not found'}) return ret
def task_delete(id): from async_ import AsyncManager task = AsyncManager.get_task(id) if task is not None: task.cancel()