Wait for n amount of milliseconds to continue executing the code in V
16:06 02 May 2024

I am building a web crawler in V to index some URLs. The problem:

I need to limit the amount of requests I send every second, and let’s say I want to send a request every two seconds.

I've used many languages before, and all of them seem to have a keyword to achieve this. For example, PHP has the sleep() function.

After reading through the documentation, I found the following (which doesn't work for me):

import time

fn main() {
   time.sleep(2000)
}

Documentation: V time.sleep

The problem is that time.sleep() seems to be used on threads, which I am not using.

Is there a way to do it, or should I simulate it with loops?

sleep vlang