AWS Lambda异步功能不起作用

时间:2019-09-16 19:04:33

标签: amazon-web-services aws-lambda boto3

我有50个lambda函数。现在,我编写了一个脚本,每15分钟调用这50个函数,如下所示:

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

我创建了一个带有boto3程序包和pickle文件的部署程序包。当我在lambda管理控制台中执行此操作时,我注意到两件事:

  1. check functions在日志中打印了两次,即使只有一张打印件也是如此

  2. 日志显示已执行的1个或2个功能。它不会打印所有功能,这意味着永远不会调用这些功能。

但是此脚本在24秒内在我的本地计算机上运行,​​并且所有功能都完美执行。有人可以帮我在AWS上运行此脚本吗?

我的泡菜文件:

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'}

上面是要调用的aws lambda函数本身

1 个答案:

答案 0 :(得分:0)

确保lambda函数的执行超时足够,以便有时间调用所有其他lambda。

enter image description here

相关问题