Reputation: 83
I'm creating a Lambda function in Python which is triggered by uploading an MP3 file to my S3 bucket. The function (which works on my local machine) is supposed to use pydub to create a waveform from the audio, however, I've run into an issue I don't know how to solve.
It seems I'm able to save the file to the /tmp
folder, but when I try to pass the file to AudioSegment.from_file(filename)
, the function ends and there are no error logs in CloudWatch.
Here's the relevant block of code:
s3.download_file(bucket_name, file_key, '/tmp/temp.mp3')
src = "/tmp/temp.mp3"
try:
print 'trying...'
audio = AudioSegment.from_file(src)
except:
print 'its breaking'
print 'it worked'
I've wrapped the problem line in a try
block to simplify the issue. CloudWatch simply logs:
START RequestId: 23af8832-061b-4c46-a226-6591bb972b5e Version: $LATEST
trying...
END RequestId: 23af8832-061b-4c46-a226-6591bb972b5e
Expected output would be:
START RequestId: 23af8832-061b-4c46-a226-6591bb972b5e Version: $LATEST
trying...
its breaking || it worked
END RequestId: 23af8832-061b-4c46-a226-6591bb972b5e
Am I missing something?
Any help would be greatly appreciated! :)
Upvotes: 2
Views: 715
Reputation: 3450
You can verify if your lambda is timing out via the AWS web console if you go to CloudWatch -> Logs -> Log Insights -> select your desired log groups -> paste the following query -> click Run Query
:
fields @timestamp, @requestId, @message, @logStream
| filter @message like "Task timed out"
| sort @timestamp desc
| limit 100
The results are all log streams from timed out tasks in your log group, which in this case has your lambda logs.
Where I found this: https://aws.amazon.com/premiumsupport/knowledge-center/lambda-verify-invocation-timeouts/
Upvotes: 1
Reputation: 83
Oh my goodness, so if anyone else gets stuck on this here's what solved it for me. The function wat timing out... I had no idea this was happening!
Find the Basic Settings
block in your function configuration tab and increase the timeout. 😂
I found the timeout error by manually creating a request and running a test from within the Lambda console.
Upvotes: 5