S
SkyFox
I'm writing a script that retrieves multiple xml files from a remote
server within a loop, and I need to build in a short delay (say, 2
seconds) between requests to avoid overloading the server. I tried to
use the sleep method to do this, but the script exits without executing
any of the code that comes after the sleep call. I searched this group
for similar problems, and I found an earlier thread ("Continuous
running thread" from Nov. 3, 2005) that seemed like it might contain a
solution, but that didn't work, either. Based on that thread, what I
have at the moment is something like:
thread = Thread.new {
# call to remote server
sleep 2
}
thread.join
I've tried putting the loop inside the thread and creating the thread
within the loop, but neither has worked. It always exits after the
sleep call. Does anyone have an idea about what might be wrong here,
or is there another way I can build in the delay?
Schuyler
server within a loop, and I need to build in a short delay (say, 2
seconds) between requests to avoid overloading the server. I tried to
use the sleep method to do this, but the script exits without executing
any of the code that comes after the sleep call. I searched this group
for similar problems, and I found an earlier thread ("Continuous
running thread" from Nov. 3, 2005) that seemed like it might contain a
solution, but that didn't work, either. Based on that thread, what I
have at the moment is something like:
thread = Thread.new {
# call to remote server
sleep 2
}
thread.join
I've tried putting the loop inside the thread and creating the thread
within the loop, but neither has worked. It always exits after the
sleep call. Does anyone have an idea about what might be wrong here,
or is there another way I can build in the delay?
Schuyler