Skip to content

Instantly share code, notes, and snippets.

@klivan

klivan/main.py Secret

Created January 25, 2019 03:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save klivan/7fb7f57ad3b7df13c1ad366faa220e93 to your computer and use it in GitHub Desktop.
Save klivan/7fb7f57ad3b7df13c1ad366faa220e93 to your computer and use it in GitHub Desktop.
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
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
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