How to handle a "wait for file" situation

J. Landman Gay jacque at hyperactivesw.com
Tue Jun 9 14:06:38 EDT 2009


Mark Smith wrote:
> Craig, you're quite right, and so is Jaque, but in this case, the script 
> is running as a cgi on a server, so has it's own exclusive copy of the 
> engine running it - so nothing else would be getting held up.

Actually, the wait command will stop everything until the wait is done, 
including all background processes. That means other copies of the Rev 
engine will also pause until the original script's wait is done. If a 
bunch of these scripts are all waiting at the same time, I could see a 
complete lockup happening.

Here's what Scott Raney said about loops like that:
"This loop uses 100% of the CPU time, regardless of the speed of the 
processor, bringing the system to its knees, causing poor feedback for 
your app, and making your system unresponsive to any other processes 
running on it."

He also mentioned: Some of the processes that can slow down or stop when 
a script uses this kind of processor-intensive repeat loop are: file and 
printer sharing, HTTP/FTP servers, network management tools, and on UNIX 
systems (including Mac OS X), people telnetting in from other systems.

A better approach while waiting for a file to appear is to use the "send 
in time" syntax to continually check for the file. When it becomes 
available, call a second handler or enter an "else if" clause that 
completes the processing.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com



More information about the use-livecode mailing list