I'm trying to launch an AWS Lambda asynchronously from a Django Python app using Boto3. The following code works fine on my local development system:
import boto3
from concurrent.futures import ThreadPoolExecutor
[.....]
endpoint_scoring_arn = "arn:aws:lambda:us-east-1:xxx:function:my-lambda-function"
data = {
'my_data_param': 'my_data',
}
# https://stackoverflow.com/a/39457165/364966
# https://stackoverflow.com/questions/40377662/boto3-client-noregionerror-you-must-specify-a-region-error-only-sometimes
boto3_client = boto3.client('lambda', region_name='us-east-1')
with ThreadPoolExecutor(max_workers=1) as executor:
future_execution = [executor.submit(boto3_client.invoke,
FunctionName=endpoint_scoring_arn,
InvocationType="Event",
Payload=json.dumps(data)
)]
try:
print("boto3 exception:")
print(future_execution[0]._exception.kwargs['report'])
except Exception as e0:
print("No boto3 exception found")
...but when I run it in production on EC2, the Lambda function never gets run. There are no error messages in my Django debug.log, or in syslog, and the above code prints out "No boto3 exception found"
.
What could account for this?