1
votes

I have 50 lambda functions. Now I wrote a script to invoke these 50 functions every 15 minutes, something like this:

import boto3
import pickle

def Handler(event, context):

    #read exams functions from pickle
    with open('result.pickle', 'rb') as file:
        all_functions = pickle.load(file)
        functions = all_functions['func']
        print('check functions')

    for items in functions:
        if 'FromDB' in items:
            print(items)
            lambda_client = boto3.client('lambda')
            response = lambda_client.invoke(FunctionName = items, InvocationType = 'Event')
            print(response)
        else:
            continue

I created a deployment package with boto3 package and the pickle file in it. When I execute this in lambda management console, 2 things I notice:

  1. check functions is printed twice in logs, event though there is just one single print

  2. The logs show either 1 or 2 functions that are executed. It doesn't print all functions, which means those functions are never invoked.

This script however runs on my local machine in 24 seconds and all functions are executed perfectly. Can someone help me to run this script on AWS?

My pickle file:

with open('result.pickle', 'rb') as file:
    all_functions = pickle.load(file)
    functions = all_functions['func']
print(functions)

{'myfunc_1', 'myfunc_2', 'myfunc_3', 'myfunc_4', 'myfunc_5'}

The above are aws lambda functions itself which are to be invoked

1
Chances are that your pickle file contains the lambda function itself. If that is the case, it might be falling prey to recurring calls and hence never really terminating correctly. Eventually AWS might be taking care of terminating it. Posting content of your pickle file would be more helpful in case the above is not an issue - The Cloud Guy
"Chances are that your pickle file contains the lambda function itself" - what do you mean by that? - Hello.World

1 Answers

0
votes

Make sure that the execution timeout of the lambda function is enough so that it has time to invoke all of the other lambdas.

enter image description here