sleep
sleep
Function
Let the current thread sleep for the specified number of milliseconds.
Syntax
sleep(millis)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| millis | Int | No | 0 | The number of milliseconds to sleep; negative numbers are treated as 0. |
Return value
| Type | Description |
|---|---|
| Empty | Return to Empty after sleeping. |
Example
result = sleep(1) // Output: Empty echo(type(result))
Notes
- This function blocks the current execution flow.
- Short
sleep()is allowed in Web requests, but the number of dormant milliseconds cannot exceedBT_IO_TIMEOUT_MS, the default is 30000 milliseconds; the entire request script will enter the blocking pool to avoid blocking Tokio Web workers. - The complete rules in web requests are found in: Web Blocking API Policy.