1

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
  • 221,139
  • 17
  • 121
  • 189
Punter Vicky
  • 14,140
  • 41
  • 164
  • 279
  • 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
  • 59,580
  • 13
  • 95
  • 104