Reputation: 19486
I've got a rate-limited endpoint I'm querying, and so I need to make KDB pause between requests. Is there a way I can block the current thread?
Upvotes: 1
Views: 1980
Reputation: 936
The solutions using system
are good for the majority of use cases. If you want an OS-agnostic method, the below lambda can be used, passing the time to wait as an argument:
{t:.z.p;while[.z.p<t+x]} 00:00:05
This approach can also be used if you're making these requests using secondary/slave threads (for example, using peach
), whereas attempting to use the system
keyword will fail in this case.
Upvotes: 3
Reputation: 2800
system"timeout 5"
on Windows OS
For reference system
lets you run any commands native to the OS. Like doing \
in the terminal e.g. \timeout 5
~ system"timeout 5"
Upvotes: 1