Quanlse/QTask.py
def _waitTask(token, taskId, downloadResult=True):
    """
    Wait for a task from the taskId
    """
    if outputInfo:
        print(f'Task {taskId} is running, please wait...')

    task = {
        "token": token,
        "taskId": taskId
    }

    stepStatus = "waiting"
    while True:
        try:
            time.sleep(pollInterval)
            ret = invokeBackend("task/checkTask", task)
            if ret["status"] in ("success", "failed", "manual_term"):
                if outputInfo:
                    print(f"status changed {stepStatus} => {ret['status']}")
                stepStatus = ret["status"]
                result = {"status": ret["status"]}

                if ret["status"] == "success" and "originUrl" in ret.get("result", {}):
                    if downloadResult:
                        originFile = _fetchResult(token, taskId)
                        result["origin"] = originFile
                        result["results"] = _fetchMeasureResult(taskId)
                    break
                elif ret["status"] == "failed":
                    result = ret["reason"]
                    break
                elif ret["status"] == "manual_term":
                    break
                else:
                    # go on loop
                    pass
            else:
                if ret["status"] == stepStatus:
                    continue

                if outputInfo:
                    print(f"status changed {stepStatus} => {ret['status']}")
                stepStatus = ret["status"]

        except Error.Error as err:
            raise err

        except Exception:
            raise Error.RuntimeError(traceback.format_exc())

    return result

    Wait for a task from the taskId
    
Wait for a task from the taskId
Wait for a task from the taskId
def _waitTask(token, taskId, downloadResult=True):
    if outputInfo:
        print(f'Task {taskId} is running, please wait...')
    task = {
        "token": token,
        "taskId": taskId
    }
    stepStatus = "waiting"
    while True:
        try:
            time.sleep(pollInterval)
            ret = invokeBackend("task/checkTask", task)
            if ret["status"] in ("success", "failed", "manual_term"):
                if outputInfo:
                    print(f"status changed {stepStatus} => {ret['status']}")
                stepStatus = ret["status"]
                result = {"status": ret["status"]}
                if ret["status"] == "success" and "originUrl" in ret.get("result", {}):
                    if downloadResult:
                        originFile = _fetchResult(token, taskId)
                        result["origin"] = originFile
                        result["results"] = _fetchMeasureResult(taskId)
                    break
                elif ret["status"] == "failed":
                    result = ret["reason"]
                    break
                elif ret["status"] == "manual_term":
                    break
                else:
                    pass
            else:
                if ret["status"] == stepStatus:
                    continue
                if outputInfo:
                    print(f"status changed {stepStatus} => {ret['status']}")
                stepStatus = ret["status"]
        except Error.Error as err:
            raise err
        except Exception:
            raise Error.RuntimeError(traceback.format_exc())
    return result
def _waitTask ( token , taskId , downloadResult = True ) : if outputInfo : print ( f'Task {taskId} is running, please wait...' ) task = { "token" : token , "taskId" : taskId } stepStatus = "waiting" while True : try : time . sleep ( pollInterval ) ret = invokeBackend ( "task/checkTask" , task ) if ret [ "status" ] in ( "success" , "failed" , "manual_term" ) : if outputInfo : print ( f"status changed {stepStatus} => {ret['status']}" ) stepStatus = ret [ "status" ] result = { "status" : ret [ "status" ] } if ret [ "status" ] == "success" and "originUrl" in ret . get ( "result" , { } ) : if downloadResult : originFile = _fetchResult ( token , taskId ) result [ "origin" ] = originFile result [ "results" ] = _fetchMeasureResult ( taskId ) break elif ret [ "status" ] == "failed" : result = ret [ "reason" ] break elif ret [ "status" ] == "manual_term" : break else : pass else : if ret [ "status" ] == stepStatus : continue if outputInfo : print ( f"status changed {stepStatus} => {ret['status']}" ) stepStatus = ret [ "status" ] except Error . Error as err : raise err except Exception : raise Error . RuntimeError ( traceback . format_exc ( ) ) return result
Wait for a task from the taskId
Wait for a task from the taskId
"""
    Wait for a task from the taskId
    """ # go on loop
token
taskId
downloadResult