0

I've written a Python script (upload.py) that is working independently of AWS Lambda. It uploads data as POST to an API. It has the following method to handle a Lambda execution:

def handler(event, context):
    print("Hello!")
    start()

When I call start() on my local machine, the script runs successfully.

When I upload the code to Lambda and run a test or initiate a trigger, nothing happens. The following is printed out:

START RequestId: 6abc0995-865c-11e6-b015-57198f9121b5 Version: $LATEST
END RequestId: 6abc0995-865c-11e6-b015-57198f9121b5
REPORT RequestId: 6abc0995-865c-11e6-b015-57198f9121b5  Duration: 2056.85 ms    Billed Duration: 2100 ms

However, when I introduce an error to the code (for example adding a string and integer), the error is printed out.

Everything in settings is correctly defined (e.g. upload.handler) and no VPC is assigned to eliminate network issues. The execution role has Administrator privileges to eliminate that as a possibility as well.

1 Answer 1

1

So it turns out that the "sys" library isn't permitted in a Lambda, which makes sense in hindsight. To deal with potential encoding issues I had the following code:

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

As suggested in another Stack Overflow thread. This apparently was blocking execution. Removal allowed the script to execute properly.

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

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.