infinite-loop

Why is it so bad to run a PHP script continuously?

独自空忆成欢 提交于 2019-12-03 13:29:08
I have a map. On this map I want to show live data collected from several tables, some of which have astounding amounts of rows. Needless to say, fetching this information takes a long time. Also, pinging is involved. Depending on servers being offline or far away, the collection of this data could vary from 1 to 10 minutes. I want the map to be snappy and responsive, so I've decided to add a new table to my database containing only the data the map needs. That means I need a background process to update the information in my new table continuously. Cron jobs are of course a possibility, but I

Python - A keyboard command to stop infinite loop? [duplicate]

北城以北 提交于 2019-12-03 10:46:44
This question already has answers here : Why can't I handle a KeyboardInterrupt in python? (6 answers) Possible Duplicate: Why can't I handle a KeyboardInterrupt in python? I was playing around with some Python code and created an infinite loop: y = 0 x = -4 itersLeft = x while(itersLeft<0): y = y + x itersLeft = itersLeft - 1 print "y = ",y, "itersLeft = ", itersLeft print y Is there a keyboard shortcut that would allow me to stop the looping - allowing me to fix the loop and then restart it? I've tried Ctrl + C and didn't have any luck. If it helps I'm using a Windows 7 environment. Thanks.

how do I create an infinite loop in JavaScript [duplicate]

做~自己de王妃 提交于 2019-12-03 10:36:50
问题 This question already has answers here : JavaScript Infinitely Looping slideshow with delays? (10 answers) Closed 5 years ago . I want to create an infinite loop in JavaScript. What are some ways to achieve this: eg for (var i=0; i<Infinity; i++) {} 回答1: By omitting all parts of the head, the loop can also become infinite: for (;;) {} 回答2: You can also use a while loop while (true) { //your code } 来源: https://stackoverflow.com/questions/24977456/how-do-i-create-an-infinite-loop-in-javascript

Detecting infinite loop in brainfuck program

夙愿已清 提交于 2019-12-03 08:29:28
问题 I have written a simple brainfuck interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number of cases, and hence the GA gets stuck at the point. So, I need a mechanism to detect infinite loops and avoid executing that code in bf. One obvious (trivial) case is when I have [] I can detect this and refuse to run that program. For the non-trivial

jQuery .animate() callback infinite loop

元气小坏坏 提交于 2019-12-03 08:28:13
A simple question: Why can I do this var start = function() { $('#element').animate({}, 5000, 'linear', start); } but not this function start() { $('#element').animate({}, 5000, 'linear', start()); } ? The first works perfectly, restarting the animation after it completes. The second simply causes an infinite loop. Either use function start() { $('#element').animate({}, 5000, 'linear', start); } or function start() { $('#element').animate({}, 5000, 'linear', function(){ start(); }); } second case is useful if you want to actually pass some arguments to start.. it's because in the first one you

strange string.IndexOf behavour

守給你的承諾、 提交于 2019-12-03 08:09:52
I wrote the following snippet to get rid of excessive spaces in slabs of text int index = text.IndexOf(" "); while (index > 0) { text = text.Replace(" ", " "); index = text.IndexOf(" "); } Generally this works fine, albeit rather primative and possibly inefficient. Problem When the text contains " - " for some bizzare reason the indexOf returns a match! The Replace function doesn't remove anything and then it is stuck in a endless loop. Any ideas what is going on with the string.IndexOf? Ah, the joys of text. What you most likely have there, but got lost when posting on SO, is a "soft hyphen".

How do I handle an infinite list of IO objects in Haskell?

旧城冷巷雨未停 提交于 2019-12-03 06:56:07
I'm writing a program that reads from a list of files. The each file either contains a link to the next file or marks that it's the end of the chain. Being new to Haskell, it seemed like the idiomatic way to handle this is is a lazy list of possible files to this end, I have getFirstFile :: String -> DataFile getNextFile :: Maybe DataFile -> Maybe DataFile loadFiles :: String -> [Maybe DataFile] loadFiles = iterate getNextFile . Just . getFirstFile getFiles :: String -> [DataFile] getFiles = map fromJust . takeWhile isJust . loadFiles So far, so good. The only problem is that, since

What could cause an Android activity to relaunch itself infinitely when returning from camera?

随声附和 提交于 2019-12-03 06:48:55
I have a weird bug in my application that causes an activity to relaunch itself in an infinite loop when I'm returning from a camera application, after taking a picture. The UI flow is like this: Main Activity -> Accept Photo activity -> in onCreate() open camera with startActivityForResult() Camera screen -> take picture (or cancel) -> return to Accept Photo The Accept Photo screen is created completely and immediately stopped and recreated in an infinite loop The weird part is that it only happens for some cameras. On my Nexus S running Jellybean, the stock camera behaves correctly, while

How to handle an “infinite” IEnumerable?

二次信任 提交于 2019-12-03 05:38:37
问题 A trivial example of an "infinite" IEnumerable would be IEnumerable<int> Numbers() { int i=0; while(true) { yield return unchecked(i++); } } I know, that foreach(int i in Numbers().Take(10)) { Console.WriteLine(i); } and var q = Numbers(); foreach(int i in q.Take(10)) { Console.WriteLine(i); } both work fine (and print out the number 0-9). But are there any pitfalls when copying or handling expressions like q ? Can I rely on the fact, that they are always evaluated "lazy"? Is there any danger

NodeJS memory consumption in an infinite loop

限于喜欢 提交于 2019-12-03 05:28:37
I don't know if this is a bug with Node or V8, but if I run the following code the node process leaks memory. The GC never seems to kick in and in a few seconds it's consuming >1GB of memory. This is unexpected behavior. Am I missing something? Here's the code: for(;;) { console.log(1+1); } Obviously, this is a little bit of a contrived situation, but I can see an issue with a long-running process that would never free memory. Edit: I tried both with v0.5.10 (unstable) and v0.4.12 (stable) and the unstable version performs a little bit better---the stable version just stops outputting to the