-
-
Save klivan/7fb7f57ad3b7df13c1ad366faa220e93 to your computer and use it in GitHub Desktop.
This file contains 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 json | |
import boto3 | |
client = boto3.client('lambda') | |
BATCH_SIZE = 100 | |
def lambda_handler(event, context): | |
urls = [] | |
for i in range(0, 10000): | |
urls.append('url_{}'.format(i)) | |
chunks = [urls[i:i + BATCH_SIZE] for i in range(0, len(urls), BATCH_SIZE)] | |
for chunk in chunks: | |
response = client.invoke( | |
FunctionName='triggerer', | |
InvocationType='Event', | |
Payload=json.dumps({'urls': chunk}) | |
) | |
return |
This file contains 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 json | |
import boto3 | |
client = boto3.client('lambda') | |
def lambda_handler(event, context): | |
for url in event.get('urls', []): | |
response = client.invoke( | |
FunctionName='testLambdaWorker', | |
InvocationType='Event', | |
Payload=json.dumps({'url': url}) | |
) | |
return |
This file contains 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 json | |
import time | |
def lambda_handler(event, context): | |
time.sleep(0.5) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment