问题描述
我正在尝试使用aioboto3库异步调用SageMaker上的端点。 下面是用于此的简单python代码
import asyncio
import aioboto3
async def entry():
sagemaker_client = aioboto3.session.Session(profile_name='mlbeta').client('sagemaker-runtime')
request_body = "...<some-payload>..."
response = await sagemaker_client.invoke_endpoint(
EndpointName='ASMSummaryGenerator',Body=request_body,ContentType='application/json'
)
response_json = response['Body'].read().decode('utf-8')
print(response_json)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(entry())
运行此代码时出现以下错误
/Users/rppatwa/anaconda3/bin/python /Volumes/Unix/workplace/RPPythonTestsWS/src/RPPythonTests/src/PythonPlayground/AsyncBoto3SpeakableTest.py
Traceback (most recent call last):
File "/Volumes/Unix/workplace/RPPythonTestsWS/src/RPPythonTests/src/PythonPlayground/AsyncBoto3SpeakableTest.py",line 43,in <module>
loop.run_until_complete(entry())
File "/Users/rppatwa/anaconda3/lib/python3.7/asyncio/base_events.py",line 584,in run_until_complete
return future.result()
File "/Volumes/Unix/workplace/RPPythonTestsWS/src/RPPythonTests/src/PythonPlayground/AsyncBoto3SpeakableTest.py",line 30,in entry
response = await sagemaker_client.invoke_endpoint(
AttributeError: 'ClientCreatorContext' object has no attribute 'invoke_endpoint'
sys:1: RuntimeWarning: coroutine 'AioSession._create_client' was never awaited
aiboto3库是否支持等待invoke_endpoint()api?如果没有,如何通过其他方式实现异步执行。感谢您的回应。预先感谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)