{"id":13667651,"url":"https://github.com/vumdao/multithread-in-lambda","last_synced_at":"2025-04-26T18:30:29.655Z","repository":{"id":116192881,"uuid":"327057706","full_name":"vumdao/multithread-in-lambda","owner":"vumdao","description":null,"archived":false,"fork":false,"pushed_at":"2021-01-05T16:52:08.000Z","size":2,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-11T03:33:11.595Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vumdao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-01-05T16:36:01.000Z","updated_at":"2024-03-04T22:10:46.000Z","dependencies_parsed_at":"2023-03-10T04:45:20.987Z","dependency_job_id":null,"html_url":"https://github.com/vumdao/multithread-in-lambda","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vumdao%2Fmultithread-in-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vumdao%2Fmultithread-in-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vumdao%2Fmultithread-in-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vumdao%2Fmultithread-in-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vumdao","download_url":"https://codeload.github.com/vumdao/multithread-in-lambda/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251035058,"owners_count":21526300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T07:00:45.293Z","updated_at":"2025-04-26T18:30:29.358Z","avatar_url":"https://github.com/vumdao.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://dev.to/vumdao\"\u003e\n    \u003cimg alt=\"Multi threading in lambda function\" src=\"https://dev-to-uploads.s3.amazonaws.com/i/8w206lcs798a2mfit9tb.png\" width=\"500\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003ch3 align=\"center\"\u003e\n  \u003cb\u003eHere's a simple multi-threaded program in lambda function.\u003c/b\u003e\n\u003c/h3\u003e\n\n\n## What’s In This Document \n- [Create lambda function using chalice](#-Create-lambda-function-using-chalice)\n- [Run test](#-Run-test)\n- [Check result](#-Check-result)\n\n#\n\n### 🚀 **[Create lambda function using chalice](#-Create-lambda-function-using-chalice)**\n- `app.py`\n```\nfrom chalice import Chalice\nimport threading\nimport time\nfrom datetime import datetime\n\n\napp = Chalice(app_name='multithread-test')\napp.debug = True\n\n\ndef run_thread(msg):\n    app.log.debug(f\"Call {msg} and sleep, timestamp {datetime.now()}\")\n    time.sleep(5)\n\n\n@app.lambda_function(name='multithread-test')\ndef handler(event, context):\n    thread_list = list()\n    for i in range(0, 5):\n        msg = f'thread-{i}'\n        thread = threading.Thread(target=run_thread, args=(msg,))\n        thread_list.append(thread)\n        thread.start()\n\n    for t in thread_list:\n        t.join()\n\n    return \"Done!\"\n```\n- Create AWS chalice new project\n```\n⚡ $ chalice new-project multithread-test\n```\n- Deploy function\n```\n⚡ $ chalice deploy \nCreating deployment package.\nCreating IAM role: multithread-test-dev\nCreating lambda function: multithread-test-dev-multithread-test\nResources deployed:\n  - Lambda ARN: arn:aws:lambda:ap-northeast-2:1111111111111:function:multithread-test-dev-multithread-test\n```\n\n### 🚀 **[Run test](#-Run-test)**\n- Invoke lambda function using aws-cli\n```\n⚡ $ aws lambda invoke --function-name multithread-test-dev-multithread-test --region ap-northeast-2 outfile \n{\n    \"StatusCode\": 200,\n    \"ExecutedVersion\": \"$LATEST\"\n}\n```\n\n### 🚀 [Check result](#-Check-result)\n![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/evb0w86gjnfaoa8w4nuq.png)\n\n**Read More**\n- [Pelican-resume with docker-compose and AWS + CDK](https://dev.to/vumdao/pelican-resume-with-docker-compose-and-aws-cdk-33e5)\n- [Using Helm Install Botkube Integrate With Slack On EKS](https://dev.to/vumdao/using-helm-install-botkube-integrate-with-slack-on-eks-gmn)\n- [Ansible AWS EC2 Dynamic Inventory Plugin](https://dev.to/vumdao/ansible-aws-ec2-dynamic-inventory-plugin-3bme)\n- [How To List All Enabled Regions Within An AWS account](https://dev.to/vumdao/list-all-enabled-regions-within-an-aws-account-4oo7)\n- [Using AWS KMS In AWS Lambda](https://dev.to/vumdao/using-aws-kms-in-aws-lambda-2jm2)\n- [Create AWS Backup Plan](https://dev.to/vumdao/create-aws-backup-plan-a0f)\n- [Techniques For Writing Least Privilege IAM Policies](https://dev.to/vumdao/techniques-for-writing-least-privilege-iam-policies-4fc7)\n- [EKS Persistent Storage With EFS Amazon Service](https://dev.to/vumdao/eks-persistent-storage-with-efs-amazon-service-14ei)\n- [Create k8s Cronjob To Schedule Delete Expired Files](https://dev.to/vumdao/create-k8s-cronjob-to-schedule-delete-expired-files-1i41)\n- [Amazon ECR - Lifecycle Policy Rules](https://dev.to/vumdao/amazon-ecr-lifecycle-policy-rules-1l59)\n- [Connect Postgres Database Using Lambda Function](https://dev.to/vumdao/connect-postgres-database-using-lambda-function-1mca)\n- [Using SourceIp in ALB Listener Rule](https://dev.to/vumdao/using-sourceip-in-alb-listener-rule-377b)\n- [Amazon Simple Systems Manager (SSM)](https://dev.to/vumdao/amazon-simple-systems-manager-ssm-2pb0)\n- [Invalidation AWS CDN Using Boto3](https://dev.to/vumdao/invalidation-aws-cdn-using-boto3-2k9g)\n- [Create AWS Lambda Function Triggered By S3 Notification Event](https://dev.to/vumdao/create-aws-lambda-function-triggered-by-s3-notification-event-9p0)\n- [CI/CD Of Invalidation AWS CDN Using Gitlab Pipeline](https://dev.to/vumdao/ci-cd-of-invalidation-aws-cdn-using-gitlab-pipeline-34op)\n- [Create CodeDeploy](https://dev.to/vumdao/create-codedeploy-4425)\n- [Gitlab Pipeline With AWS Codedeploy](https://dev.to/vumdao/gitlab-pipeline-with-aws-codedeploy-30cl)\n- [Create AWS-CDK image container](https://dev.to/vumdao/create-aws-cdk-image-container-43ei)\n- [Deploy Python Lambda Functions With Container Image](https://dev.to/vumdao/deploy-python-lambda-functions-with-container-image-5hgj)\n- [Custom CloudWatch Events](https://dev.to/vumdao/custom-cloudwatch-events-4j3j)\n- [How To Get Lastest Image Version in AWS ECR](https://dev.to/vumdao/how-to-get-lastest-image-version-in-aws-ecr-4op2)","funding_links":[],"categories":["Made with Chalice"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvumdao%2Fmultithread-in-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvumdao%2Fmultithread-in-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvumdao%2Fmultithread-in-lambda/lists"}