def METHOD_NAME(
    access_token, inst_id, cluster_id, instance_name, category, kind, ns_name, project_id, username=None, conf=None
):
    """轮训任务状态，并启动创建任务"""
    is_polling = True
    while is_polling:
        result = get_k8s_category_status(
            access_token, cluster_id, instance_name, category=category, namespace=ns_name, project_id=project_id
        )
        if result.get("code") == 0 and not result.get("data"):
            is_polling = False
        time.sleep(POLLING_INTERVAL_SECONDS)
    if str(inst_id) != "0":
        # 执行创建任务
        info = InstanceConfig.objects.get(id=inst_id)
        conf = json.loads(info.config)
    resp = create_instance(
        access_token, cluster_id, ns_name, conf, category=category, kind=kind, project_id=project_id
    )
    if str(inst_id) == "0":
        return
    # 更新instance状态
    if resp.get("code") != ErrorCode.NoError:
        update_instance_record_status(info, "rebuild", status="Error", is_bcs_success=False)
        # 记录失败事件
        conf_instance_id = conf.get("metadata", {}).get("labels", {}).get("io.tencent.paas.instanceid")
        err_msg = resp.get("message") or _("实例化失败，已通知管理员!")
        logger.error("实例化失败, 实例ID: %s, 详细:%s" % (inst_id, err_msg))
        try:
            InstanceEvent(
                instance_config_id=inst_id,
                category=category,
                msg_type=EventType.REQ_FAILED.value,
                instance_id=conf_instance_id,
                msg=err_msg,
                creator=username,
                updator=username,
                resp_snapshot=json.dumps(resp),
            ).save()
        except Exception as error:
            logger.error(u"存储实例化失败消息失败，详情: %s" % error)
    else:
        update_instance_record_status(info, "rebuild", status="Running", is_bcs_success=True)