2

I have an API built using python running on AWS Lambda. This lambda has a logic to determine if a specific condition is met and proceed with rest of the logic only if the condition is met. In this scenario , should I use exit or return if condition is not met to exit the lambda?

    if status != 'PENDING':
       exit()

or

    if status != 'PENDING':
       return
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Punter Vicky
  • 15,954
  • 56
  • 188
  • 315
  • Related: https://stackoverflow.com/questions/52739632/lambda-python-exit-code and https://stackoverflow.com/questions/51780706/stop-a-lambda-function-in-python – jarmod Jul 31 '19 at 22:11

1 Answers1

3

You should use following general syntax structure when creating a handler function in Python:

def handler_name(event, context): 
    ...
    return some_value

If you don't want to return a value then simply return or return None. A return value is optional.

jarmod
  • 71,565
  • 16
  • 115
  • 122