Esempio n. 1
0
 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
Esempio n. 2
0
 def task_delete(id):
     from async_ import AsyncManager
     task = AsyncManager.get_task(id)
     if task is not None:
         task.cancel()