2

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! :)

2
  • How could there possibly be any error logged? You are explicitly throwing away all information about errors. Commented Apr 13, 2019 at 2:57
  • 1
    Right, well before I added the try block there were no errors logged, and with the try/except block, I would expect the next line in the logs to be either "it's breaking" or "it worked". Commented Apr 13, 2019 at 3:01

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

That is soo nasty!! I spent an hour debugging my code before I found this out. You are a legend... SMH, why CloudWatch doesnt put error "TIMEOUT" is beyond me!
It does, you get a message like:- "Task timed out after <timeout specified>"
1

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/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.