sleep-for
The sleep-for function waits for the specified number of seconds before returning the second argument. Depending on what you would like the function to return, the second argument can be of any type (a string, number, stream, etc.). You can also use any suitable expression as the second argument. If you do not need a specific result, you can use, for example, 0 as the second argument. The sleep-for function can be particularly useful in On-Retry blocks (see example below). You can also use this function for testing purposes.
Signature
sleep-for(number as number, a as any type) -> a
Parameters
Name | Type | Description |
---|---|---|
number | number | The number of seconds for which the step will be delayed. |
a | any type | Returns the result. |
Example
The example below shows a Protected block that calls the /system/ftp/retrieve function to download a file from the FTP server to the local directory. If the execution of the retrieve function fails, this step will be retried five times. On each retry, the sleep-for function will be computed. FlowForce Server will wait for 30 seconds, return the 'Retrying after 30 seconds' string, and then try downloading the file again.