Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
aaronrums
Contributor II
Contributor II

Most sensible and performant way to do something every X seconds

I'm working on a job to continually call an API every X seconds (lets say 30 seconds), extract some data from the response (lets call it the "status" field of some JSON) and then either kill the job if the status matches some desired status, or wait and call the API again. In the future I might want to extend this time to 10 minutes, up to 30 minutes maybe.

What do you think is the best way to do this? I currently have a setup of an outer loop that determines the Number of times to call the API, then an inner loop that uses some datetime logic to continually check if X number of seconds has passed (see attachment, but ignore if you already get what I'm saying). But I'm worried about performance for this method, since the inner loop could easily run tens of thousands of times depending on how many seconds it is waiting.

I also see the infinite loop option, but that number is in milliseconds. When using this component, is it the developer's responsibility to create some logical check to eventually break out of the loop?

Labels (2)
1 Reply
aaronrums
Contributor II
Contributor II
Author

For anyone who stumbles upon this...turns out there is a tSleep component that does this exact thing! Pretty easy, and way better than having a loop that checks the elapsed time every iteration.