Created
February 25, 2019 19:53
-
-
Save cfbarbero/ec14ef77e5a15f67132f03fdff8c8d2d to your computer and use it in GitHub Desktop.
Python data structure for handling reuse of resources across aws lambda invocations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
from .some_object import SomeObject | |
class some_lambda: | |
def __init__(self): | |
self.instance_id = uuid.uuid4() | |
self.someobject = SomeObject() | |
def handle(self, event, context): | |
self.someobject.somemethod() | |
INSTANCE = None | |
def handler(event, context): | |
global INSTANCE | |
if not INSTANCE: | |
INSTANCE = some_lambda() | |
INSTANCE.handle(event, context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment