The discussion in this post http://www.inductiveautomation.com/forum/viewtopic.php?p=11906#p11906 about problems of high CPU usage if you had a continuously looping script got me thinking. What if the loop has a sleep statement so it does not tie up the CPU.
So I placed the following code in a Gateway start-up script:
#Do some tasks
system.file.writeFile(“C:\Mydebug.txt”, time.strftime(’%x %X’) + ‘\r\n’, 1)
It does run in its own thread and because of the sleep, the CPU usage is low. But it does cause some other problems. With the script running I can not make any edits to any Gateway script in Designer. I just get a timeout when I try to save. I also could not restart the Gateway. The only easy way I found to get out of this situation was to make the Mydebug.txt file read-only so that the script would error out and stop. Then everything was back to normal.
I know you can’t protect from every type of scripting error but getting into a continuous loop is a fairly common type of programming problem.
Also, since the module API is not available someone might want to make a socket connection and keep it open in a continuously running script.