Reputation: 363
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.
Upvotes: 0
Views: 789
Reputation: 363
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.
Upvotes: 1