0 votes
1 view
in AWS by (16.7k points)

For instance:

count = 0

        while True:

            try:

                if count == 5:

                    break

                snap = ec.create_snapshot(

                    VolumeId=vol_id,

                    Description=instance['InstanceId']

                )

                break

            except Exception as e:

                print(e)

                sleep(180)

                count = count + 1

So If I have a lot of instances and errors then it could be a long time of running lambda. What could be alternative to put Lambda to sleep?

1 Answer

0 votes
by (39.6k points)

You will still be charged. So you will pay them for the time a function takes to complete its execution or when you have the set the timeout. Calling sleep() won’t stop the execution of the function, so you will still be charged for that time too. Make sure, you stop your function after your functions task completes and set the function timeout accordingly.

...