How to make lambda function wait a certain time to be executed? I used time.sleep(), but it doesn't work

0

How to make lambda function wait a certain time to be executed? I used time.sleep(), but it doesn't work I want Lambda to take s objects from the bucket and send it to another bucket, but at a certain time, I want it to take an object and then it takes 5s to send another object.

  • I'm curious, why do you need to include a 5-second wait between sending to the other bucket?

2回答
3
承認された回答

Use a Step Function. A Wait state allows the step function to wait for a specified time interval - https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-wait-state.html

You can then create a Task to invoke the lambda function - https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-task-state.html

profile pictureAWS
エキスパート
回答済み 1年前
profile pictureAWS
エキスパート
レビュー済み 1年前
2

You can't really wait for a Lambda function to be executed. You need to define what is the trigger that invokes the function. I am not sure what exactly you are trying to do, but I think you have a few options:

  1. You can use EventBridge scheduled events if you need to invoke a function on some schedule.
  2. Send a delayed messages to SQS with a Lambda trigger.
  3. Launch a state machine and use a wait state.
profile pictureAWS
エキスパート
Uri
回答済み 1年前
profile pictureAWS
エキスパート
レビュー済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ