does anyone know a Scheme function that delays yours program for a certain time?
I know the most languages have a function where you say for how many time you want that the program must wait, but I can't find it in Scheme.
I know the "delay" function in Scheme but that's not what I want, it only gives you a promise but don't stop running you program for a few seconds.
Thanks for your help! :)
This depends on the interpreter being used (it's implementation-dependent). For instance, in Racket you can call the sleep procedure:
(display "Hello ") (sleep 2) (display "World!")
From the documentation:
(sleep [secs]) → void? Causes the current thread to sleep until at least secs seconds have passed after it starts sleeping. A zero value for secs simply acts as a hint to allow other threads to execute. The value of secs can be a non-integer to request a sleep duration to any precision; the precision of the actual sleep time is unspecified.
Related
After a long period of time of reading, It's my first post here. :)
My question is the following:
Using JMeter, I have to execute 10000 requests, but between every 1000 of them, I should have sleep time (from 0 to 1000 => sleep time => from 1000 to 2000 => sleep time => ...).
I was able to do that using if clause and '__counter(FALSE,)' with pause between every 1000 requests, but it's working only on one thread. If I set >1 threads, it skipping if clause and sleep time is not activated. Far as I know, first parameter of the "counter" function makes it "global" if it is FALSE, but I am confused why the if clause is skipped, if more than 1 thread is used.
I'm checking the counter with groovy func: ${__groovy("${__counter(FALSE,)}" == "1000")}
How do you know that the "sleep time is not activated"?
Your "sleep time" will be "activated" only once when the counter reaches 1000, on 2000 and so on the condition will not be met
Inlining JMeter functions or variables into Groovy scripts is not very recommended, consider switching to __jexl3() function and changing your expression to something like:
${__jexl3(${__counter(FALSE,)} % 1000 == 0,)}
Demo:
More information: 6 Tips for JMeter If Controller Usage
In Excel Power Query (PQ) 2016, is there such a function that can insert a "SLEEP 15 seconds" before proceeding? Not a pause, but a sleep function.
Problem:
I wrote a function in PQ to query: https://westus.api.cognitive.microsoft.com/text/analytics/v2.0. That function works fine, as designed.
I have a worksheet with 10K tweets that I want to pass to that function. When I do, it gets to ~60 or so complete and I get an ERROR line in PQ. A look at Fiddler says this:
message=Rate limit is exceeded. Try again in 11 seconds. statusCode=429
I think if I insert a SLEEP 5 second (equivalent) command into the PQ function, it won't do this.
Help & thanks.
You want Function.InvokeAfter
Function.InvokeAfter(function as function, delay as duration) as any
Here's an example:
= Function.InvokeAfter( () => 2 + 2, #duration(0,0,0,5))
Returns 4 after waiting 5 seconds.
To answer a question you didn't ask yet, if you're going to execute the exact same Web.Contents call a second time, you may need to use the
[IsRetry = true]
option of Web.Contents to indicate you actually want to run the web request again..
I am getting into ruby and have been using threads for a little while now with out fully understanding them. I notice that when adding a thread to an array and if I add a sleep() command as the first command the thread does not run until I do a join which is mostly what I want. So I have 2 questions.
1.Is that suppose to happen?
2.Is there a better way to do that other then the way I'm doing it. Here is a sample code that I have to show what I'm talking about.
job = Array.new
10.times do |n|
job << Thread.new do
sleep 0.001
puts "done #{n}"
end
end
#job.each do |t|
#t.join
#end
puts "End of script"
Output is
End of script
If I remove the comments output is
done 1
done 0
done 7
done 6
done 5
done 4
done 3
done 2
done 9
done 8
End of script
So I use this now but I don't understand why it does that. Sometimes I notice even doing something like `echo hi` instead of sleep does the trick.
Thanks in advance.
Timing of threads isn't a defined behavior. Once you put them to sleep, they will be put in a queue to be run later. You can't ever expect it to run one way or another.
Your main program doesn't take very long to run, so it is likely to happen to finish before your other threads get picked back up to run again. Really, when you think about it, 0.001 seconds is quite a long time to computer, so spinning off 10 threads in that time is likely to happen -- but even if it takes longer, there is no guarantee the thread will resume immediately after .001 seconds. Often there's really no guarantee it won't start before .001 seconds, either, but sleep calls usually don't end early.
When you add the join calls, you are introducing additional time into your main thread which allows the other threads time to run, so this behavior is expected.
Is there any notable difference between
sleep 10
and
wait_until(10)
They both seem to do the same thing: wait 10 seconds then proceed to the next step
sleep just does nothing for the specified time. wait_until takes a block. It waits until the block evaluates to true or times out. If no block is given they act the same.
I'd like to run an applescript for a determined amount of time.
When the counter reaches 0 the script should stop working.
I've found online a timer code like this one:
set input to text returned of (display dialog "Enter length of timer" default answer "")
delay input
beep
But instead of waiting for that amount of time I'd like to perform all the cycles and actions of my script. Is there any easy way to achieve that?
set start to current date
repeat
say "a"
if (current date) - start ≥ 3 then exit repeat
delay 1
end repeat