Python 3.x AWS Step函数描述了_执行
我通过使用boto3.client('stepfunctions')中的start_execution调用执行来运行状态机,该客户端成功地执行了状态机 现在我想获取执行输出,所以我使用descripe\u Execution。但问题是当它记录时,我无法获得输出,因为状态仍在运行。我如何使此描述_执行等待状态成功Python 3.x AWS Step函数描述了_执行,python-3.x,amazon-web-services,boto3,aws-step-functions,Python 3.x,Amazon Web Services,Boto3,Aws Step Functions,我通过使用boto3.client('stepfunctions')中的start_execution调用执行来运行状态机,该客户端成功地执行了状态机 现在我想获取执行输出,所以我使用descripe\u Execution。但问题是当它记录时,我无法获得输出,因为状态仍在运行。我如何使此描述_执行等待状态成功 SF_CLIENT = boto3.client('stepfunctions') sf_output = SF_CLIENT.start_execution(
SF_CLIENT = boto3.client('stepfunctions')
sf_output = SF_CLIENT.start_execution(
stateMachineArn=os.environ['STATE_MACHINE_ARN'], input=input)
sf_response = SF_CLIENT.describe_execution(
executionArn=sf_output['executionArn'])
status = sf_response['status']
while status != 'SUCCEEDED':
sf_response = SF_CLIENT.describe_execution(
executionArn=sf_output['executionArn'])
LOGGER.info("%s: %s" % ("EXECUTION STILL RUNNING", sf_response))
if status != 'SUCCEEDED':
continue
elif status == 'SUCCEEDED':
break
LOGGER.info("%s: %s" % ("STEP FUNCTION EXECUTION OUTPUT", sf_output))
LOGGER.info("%s: %s" % ("STEP FUNCTION EXECUTION RESPONSE", sf_response))
正如您所了解的,StartExecution是异步的,不会等待执行完成 以下是一些需要考虑的选项:
- 使用StartSyncExecution返回结果,本质上是同步操作:
- 在执行结束时,添加执行后要执行的任何操作作为步骤
- 通过发送SQs、事件桥等来触发下一个操作,。。。事件作为状态机中的最后一步
- 通过选中描述执行或云监视事件,等待执行完成。但这个解决方案应该是你最后的选择。有许多缺点是没有缺点的。描述执行有速率限制和其他一些限制要考虑。