Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vumdao/multithread-in-lambda
https://github.com/vumdao/multithread-in-lambda
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/vumdao/multithread-in-lambda
- Owner: vumdao
- Created: 2021-01-05T16:36:01.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-05T16:52:08.000Z (almost 4 years ago)
- Last Synced: 2024-08-02T07:02:10.305Z (4 months ago)
- Language: Python
- Size: 1.95 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Here's a simple multi-threaded program in lambda function.## Whatβs In This Document
- [Create lambda function using chalice](#-Create-lambda-function-using-chalice)
- [Run test](#-Run-test)
- [Check result](#-Check-result)#
### π **[Create lambda function using chalice](#-Create-lambda-function-using-chalice)**
- `app.py`
```
from chalice import Chalice
import threading
import time
from datetime import datetimeapp = Chalice(app_name='multithread-test')
app.debug = Truedef run_thread(msg):
app.log.debug(f"Call {msg} and sleep, timestamp {datetime.now()}")
time.sleep(5)@app.lambda_function(name='multithread-test')
def handler(event, context):
thread_list = list()
for i in range(0, 5):
msg = f'thread-{i}'
thread = threading.Thread(target=run_thread, args=(msg,))
thread_list.append(thread)
thread.start()for t in thread_list:
t.join()return "Done!"
```
- Create AWS chalice new project
```
β‘ $ chalice new-project multithread-test
```
- Deploy function
```
β‘ $ chalice deploy
Creating deployment package.
Creating IAM role: multithread-test-dev
Creating lambda function: multithread-test-dev-multithread-test
Resources deployed:
- Lambda ARN: arn:aws:lambda:ap-northeast-2:1111111111111:function:multithread-test-dev-multithread-test
```### π **[Run test](#-Run-test)**
- Invoke lambda function using aws-cli
```
β‘ $ aws lambda invoke --function-name multithread-test-dev-multithread-test --region ap-northeast-2 outfile
{
"StatusCode": 200,
"ExecutedVersion": "$LATEST"
}
```### π [Check result](#-Check-result)
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/evb0w86gjnfaoa8w4nuq.png)**Read More**
- [Pelican-resume with docker-compose and AWS + CDK](https://dev.to/vumdao/pelican-resume-with-docker-compose-and-aws-cdk-33e5)
- [Using Helm Install Botkube Integrate With Slack On EKS](https://dev.to/vumdao/using-helm-install-botkube-integrate-with-slack-on-eks-gmn)
- [Ansible AWS EC2 Dynamic Inventory Plugin](https://dev.to/vumdao/ansible-aws-ec2-dynamic-inventory-plugin-3bme)
- [How To List All Enabled Regions Within An AWS account](https://dev.to/vumdao/list-all-enabled-regions-within-an-aws-account-4oo7)
- [Using AWS KMS In AWS Lambda](https://dev.to/vumdao/using-aws-kms-in-aws-lambda-2jm2)
- [Create AWS Backup Plan](https://dev.to/vumdao/create-aws-backup-plan-a0f)
- [Techniques For Writing Least Privilege IAM Policies](https://dev.to/vumdao/techniques-for-writing-least-privilege-iam-policies-4fc7)
- [EKS Persistent Storage With EFS Amazon Service](https://dev.to/vumdao/eks-persistent-storage-with-efs-amazon-service-14ei)
- [Create k8s Cronjob To Schedule Delete Expired Files](https://dev.to/vumdao/create-k8s-cronjob-to-schedule-delete-expired-files-1i41)
- [Amazon ECR - Lifecycle Policy Rules](https://dev.to/vumdao/amazon-ecr-lifecycle-policy-rules-1l59)
- [Connect Postgres Database Using Lambda Function](https://dev.to/vumdao/connect-postgres-database-using-lambda-function-1mca)
- [Using SourceIp in ALB Listener Rule](https://dev.to/vumdao/using-sourceip-in-alb-listener-rule-377b)
- [Amazon Simple Systems Manager (SSM)](https://dev.to/vumdao/amazon-simple-systems-manager-ssm-2pb0)
- [Invalidation AWS CDN Using Boto3](https://dev.to/vumdao/invalidation-aws-cdn-using-boto3-2k9g)
- [Create AWS Lambda Function Triggered By S3 Notification Event](https://dev.to/vumdao/create-aws-lambda-function-triggered-by-s3-notification-event-9p0)
- [CI/CD Of Invalidation AWS CDN Using Gitlab Pipeline](https://dev.to/vumdao/ci-cd-of-invalidation-aws-cdn-using-gitlab-pipeline-34op)
- [Create CodeDeploy](https://dev.to/vumdao/create-codedeploy-4425)
- [Gitlab Pipeline With AWS Codedeploy](https://dev.to/vumdao/gitlab-pipeline-with-aws-codedeploy-30cl)
- [Create AWS-CDK image container](https://dev.to/vumdao/create-aws-cdk-image-container-43ei)
- [Deploy Python Lambda Functions With Container Image](https://dev.to/vumdao/deploy-python-lambda-functions-with-container-image-5hgj)
- [Custom CloudWatch Events](https://dev.to/vumdao/custom-cloudwatch-events-4j3j)
- [How To Get Lastest Image Version in AWS ECR](https://dev.to/vumdao/how-to-get-lastest-image-version-in-aws-ecr-4op2)