def METHOD_NAME():
    """
    Core script execution task. We capture this within a subfunction to allow for conditionally wrapping it with
    the change_logging context manager (which is bypassed if commit == False).
    """
    try:
        try:
            with transaction.atomic():
                script.output = script.run(data=data, commit=commit)
                if not commit:
                    raise AbortTransaction()
        except AbortTransaction:
            script.log_info("Database changes have been reverted automatically.")
            clear_webhooks.send(request)
        job.data = ScriptOutputSerializer(script).data
        job.terminate()
    except Exception as e:
        stacktrace = traceback.format_exc()
        script.log_failure(
            f"An exception occurred: `{type(e).__name__}: {e}`\n```\n{stacktrace}\n```"
        )
        script.log_info("Database changes have been reverted due to error.")
        logger.error(f"Exception raised during script execution: {e}")
        clear_webhooks.send(request)
        job.data = ScriptOutputSerializer(script).data
        job.terminate(status=JobStatusChoices.STATUS_ERRORED)
    logger.info(f"Script completed in {job.duration}")