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 Risposte
3
Risposta accettata

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
ESPERTO
con risposta un anno fa
profile pictureAWS
ESPERTO
verificato un anno fa
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
ESPERTO
Uri
con risposta un anno fa
profile pictureAWS
ESPERTO
verificato un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande