Running Lambda Functions

run_lambda(handle, event, context=None, timeout_in_seconds=None, patches=None)

Run the Lambda function handle, with the specified arguments and parameters.

Parameters:
  • handle (function) – Lambda function to call
  • event (dict) – dictionary containing event data
  • context (MockLambdaContext) – context object. If not provided, a default context object will be used.
  • timeout_in_seconds (int) – timeout in seconds. If not provided, the function will be called with no timeout
  • patches (dict) – dictionary of name-to-value mappings that will be patched inside the Lambda function
Returns:

value returned by Lambda function

Return type:

LambdaResult

LambdaResult class

class LambdaResult(summary, value=None, timed_out=False, exception=None)

Represents the result of locally running a Lambda function.

exception
Property:The exception raised by the call to the Lambda function, or None if no exception was raised
Return type:Exception
summary
Property:Summary of call to Lambda function
Return type:LambdaCallSummary
timed_out
Property:Whether the call to the Lambda function timed out
Return type:bool
value
Property:The value returned by the call to the Lambda function, or None if no value was returned.
Return type:any

LambdaCallSummary class

class LambdaCallSummary(duration_in_millis, max_memory_used_in_mb, log)
duration_in_millis

Duration of call, in milliseconds. This value may vary from the duration the call would have taken if actually run in AWS.

Property:Duration of call, in milliseconds
Return type:int
log
Property:The contents of the log for this lambda function.
Return type:str
max_memory_used_in_mb

Maximum amount of memory used during call to Lambda function, in megabytes. This value is an estimate of how much memory the call would have used if actually run in AWS. We have found that these estimates are almost always within 5MB of the amount of memory used by corresponding remote calls.

Property:Maximum amount of memory used during call to Lambda function, in megabytes.
Return type:int