What is the exact use of Utilities.sleep() function? Should we use it between function calls or API calls?
I use the Utilities.sleep(1000) in-between function calls, is it right? Will it slow down the execution time?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Utilities.sleep(milliseconds) creates a ‘pause’ in program execution, meaning it does nothing during the number of milliseconds you ask.
It surely slows down your whole process and you shouldn’t use it between function calls.
There are a few exceptions though, at least that one that I know : in SpreadsheetApp when you want to remove a number of sheets you can add a few hundreds of millisecs between each deletion to allow for normal script execution (but this is a workaround for a known issue with this specific method). I did have to use it also when creating many sheets in a spreadsheet to avoid the Browser needing to be ‘refreshed’ after execution.
Here is an example :