File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,9 +3,12 @@ A tool for distributing processes across AWS Lambda functions with built-in resu
33
44## Usage
55``` python
6- # Example lambda function
6+ # Example lambda function (should be deployed to AWS)
77# filename: example_handler.py
88# Lambda function name: example_lambda
9+ from time import sleep
10+ from random import randint
11+
912from parallelagram.remote_handler import remote_handler
1013
1114
@@ -25,6 +28,8 @@ def execute(max_time: int):
2528# Calling code to asynchronously invoke the lambda defined above and retrieve its results
2629
2730from parallelagram.launchables import Lambdable, ResponseCollector
31+
32+
2833def main ():
2934 lambda_list = [Lambdable(func_path = ' example_handler.execute' ,
3035 remote_aws_lambda_func_name = ' example_lambda' ,
Original file line number Diff line number Diff line change 22
33from aws_cdk import core
44
5- from parallelagram . parallelagram_stack import LambdaStack
5+ from stack . stack import LambdaStack
66
77
88app = core .App ()
Original file line number Diff line number Diff line change 11from random import randint
22from time import sleep
33
4+ from parallelagram .remote_handler import remote_handler
45
6+
7+ @remote_handler
58def handler (event , context ):
6- sleep_time = randint (1 , 10 )
9+ pass
10+
11+ def execute (max_time : int ):
12+ sleep_time = randint (1 , max_time )
713 print (f'sleeping for { sleep_time } seconds' )
814 sleep (sleep_time )
915 return {'message' : f'slept for { sleep_time } seconds' }
Original file line number Diff line number Diff line change @@ -91,18 +91,6 @@ def remote_handler(func):
9191
9292 If a message key is not present in the event then the decorated function handler will be invoked with the raw
9393 event and context arguments as a handler usually would be.
94-
95- Because zappa dynamically generates its handler function on deployment, it is currently not possible to use this
96- wrapper on zappa-deployed functions. Users who deploy their lambdas via zappa should use the @task (original
97- zappa wrapper) or @remote_runner function wrappers instead, which should both still play nice with the manager
98- functionalities provided in remote_manager.
99-
100- Example for a non-Zappa deployed function:
101-
102- get_request_from_s3: bool = False,
103- request_s3_bucket: str = '',
104- request_s3_key: str = '',
105- response_to_s3: str = ''
10694 """
10795
10896 @wraps (func )
File renamed without changes.
Original file line number Diff line number Diff line change 33import pytest
44
55from aws_cdk import core
6- from stack .parallelagram_stack import LambdaStack
6+ from stack .stack import LambdaStack
77
88
99def get_template ():
You can’t perform that action at this time.
0 commit comments