【发布时间】:2021-03-26 03:44:27
【问题描述】:
我有一个由 SQS 消息触发的 Lambda 函数(在 Boto3 中创建)。 Lambda 函数旨在获取上传到 S3 的对象并使用 AWS Transcribe 处理它们。正在触发 Lambda 函数,但我收到以下错误:
{
"errorMessage": "Bad handler 'lambda_handler': not enough values to unpack (expected 2, got 1)",
"errorType": "Runtime.MalformedHandlerName"
}
Function Logs
START RequestId: e6080a7f-b5b7-4995-a469-351c144bb93e Version: $LATEST
[ERROR] Runtime.MalformedHandlerName: Bad handler 'lambda_handler': not enough values to unpack (expected 2, got 1)
END RequestId: e6080a7f-b5b7-4995-a469-351c144bb93e
REPORT RequestId: e6080a7f-b5b7-4995-a469-351c144bb93e Duration: 1.64 ms Billed Duration: 2 ms Memory Size: 500 MB Max Memory Used: 50 MB
Request ID
e6080a7f-b5b7-4995-a469-351c144bb93e
这是我在 Boto3 中创建 Lambda 函数的地方:
response = l.create_function(
FunctionName = lambda_name,
Runtime = 'python3.7',
Role = lambda_role,
Handler = 'lambda_handler',
Code = {
'ZipFile': open('./transcribe.zip', 'rb').read()
},
Description = 'Function to parse content from SQS message and pass content to Transcribe.',
Timeout = 123,
MemorySize = 500,
Publish = True,
PackageType = 'Zip',
)
这就是 Lambda 函数在 AWS 控制台中的样子:
from __future__ import print_function
import time
import boto3
def lambda_handler(event, context):
transcribe = boto3.client('transcribe')
job_name = "testJob"
job_uri = "https://my-bucket1729788.s3.eu-west-2.amazonaws.com/Audio3.wav"
transcribe.start_transcription_job(
TranscriptionJobName=job_name,
Media={'MediaFileUri': job_uri},
MediaFormat='wav',
LanguageCode='en-US'
)
while True:
status = transcribe.get_transcription_job(TranscriptionJobName=job_name)
if status['TranscriptionJob']['TranscriptionJobStatus'] in ['COMPLETED', 'FAILED']:
break
print("Not ready yet...")
time.sleep(5)
print(status)
我真的不知道我哪里出错了,因为我没有发现文档特别有用,所以任何帮助都非常感谢。谢谢。
【问题讨论】:
标签: amazon-web-services aws-lambda boto3