Skip to content

Commit

Permalink
Update handler to be global if INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT=T…
Browse files Browse the repository at this point in the history
…rue (#1096)

* Update handler to be global if INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT=True

* Replace global

Co-authored-by: Frank Chiang <chiangf@@users.noreply.github.com>
Co-authored-by: javulticat <[email protected]>
  • Loading branch information
3 people authored Jan 6, 2022
1 parent 86a471c commit 465773a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions zappa/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,7 @@ def import_module_and_get_function(whole_function):

@classmethod
def lambda_handler(cls, event, context): # pragma: no cover
if not os.environ.get("INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT"):
handler = cls()
handler = global_handler or cls()
exception_handler = handler.settings.EXCEPTION_HANDLER
try:
return handler.handler(event, context)
Expand Down Expand Up @@ -664,5 +663,6 @@ def keep_warm_callback(event, context):
# be triggered.


global_handler = None
if os.environ.get("INSTANTIATE_LAMBDA_HANDLER_ON_IMPORT"):
handler = LambdaHandler()
global_handler = LambdaHandler()

0 comments on commit 465773a

Please sign in to comment.