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
전문가
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전
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
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠