Python Handler Helper for Lambda

Documentation Status


Simplify best practice for Lambda in Python, handling Lambda events and errors with detailed and standarized logs.


  • Dead simple to use, reduces the complexity of writing a Lambda with Python runtime
  • Guarantees that Source will get a response even if an exception is raised
  • Sends meaningful errors to Cloudwatch in the case of a failure
  • Threading enables best runtime performance for events with multiple records
  • JSON logging that includes request id’s, event id’s and source to assist in tracing logs relevant to a particular event


Install into the root folder of your lambda function

cd my-lambda-function/
pip install phhelper -t .

Example Usage

from phhelper import aws_lambda_helper
import json
import time

def lambda_handler(event, context):'info_test')

    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')


If the event source send multiple records to be processed, you can enable Multithreading processing, by creating a Environment variable called THREADING_ENABLED with value TRUE. This will make a loop into event records, starting a thread for each record. Your handler will receive each record in a separeted call, inside a thread model.

Batch Mode

If the event source send multiple records to be processed, the layer will execute your handler one time for each record. To disable this behaviour, just create a variable called BATCH_REQUEST with value TRUE. This option only works if the THREADING_ENABLED was not set to TRUE


You can define the general log verbosity level using a Environment variable called LOG_LEVEL and the boto3 log level using a Environment variable called BOTO_LOG_LEVEL.

The valid values for both Environment variables are: * DEBUG * INFO * WARNING * ERROR * CRITICAL

The default values are:



This library is licensed under the MIT License.