async def do_run_task(context, run_cancellable, to_cancellable_process):
    """Run the task logic.

    Returns the integer status of the task.

    args:
        context (scriptworker.context.Context): the scriptworker context.
        run_cancellable (typing.Callable): wraps future such that it'll cancel upon worker shutdown
        to_cancellable_process (typing.Callable): wraps ``TaskProcess`` such that it will stop if the worker is shutting
            down

    Raises:
        Exception: on unexpected exception.

    Returns:
        int: exit status

    """
    status = 0
    try:
        if context.config['verify_chain_of_trust']:
            chain = ChainOfTrust(context, context.config['cot_job_type'])
            await run_cancellable(verify_chain_of_trust(chain))
        status = await run_task(context, to_cancellable_process)
        generate_cot(context)
    except asyncio.CancelledError:
        log.info("CoT cancelled asynchronously")
        raise WorkerShutdownDuringTask
    except ScriptWorkerException as e:
        status = worst_level(status, e.exit_code)
        log.error("Hit ScriptWorkerException: {}".format(e))
    except Exception as e:
        log.exception("SCRIPTWORKER_UNEXPECTED_EXCEPTION task {}".format(e))
        raise
    return status
async def do_run_task ( context , run_cancellable , to_cancellable_process ) : status = 0 try : if context . config [ 'verify_chain_of_trust' ] : chain = ChainOfTrust ( context , context . config [ 'cot_job_type' ] ) await run_cancellable ( verify_chain_of_trust ( chain ) ) status = await run_task ( context , to_cancellable_process ) generate_cot ( context ) except asyncio . CancelledError : log . info ( "CoT cancelled asynchronously" ) raise WorkerShutdownDuringTask except ScriptWorkerException as e : status = worst_level ( status , e . exit_code ) log . error ( "Hit ScriptWorkerException: {}" . format ( e ) ) except Exception as e : log . exception ( "SCRIPTWORKER_UNEXPECTED_EXCEPTION task {}" . format ( e ) ) raise return status
Run the task logic.

    Returns the integer status of the task.

    args:
        context (scriptworker.context.Context): the scriptworker context.
        run_cancellable (typing.Callable): wraps future such that it'll cancel upon worker shutdown
        to_cancellable_process (typing.Callable): wraps ``TaskProcess`` such that it will stop if the worker is shutting
            down

    Raises:
        Exception: on unexpected exception.

    Returns:
        int: exit status