infinite-loop

Calling a endless Python script from PHP

百般思念 提交于 2020-03-05 06:18:11
问题 I have a PHP script that calls a python script. Both running on the same Linux server. The Python script is running in a "while true" loop. Now when I start the PHP script, it remains in an endless loop and never ends. If i delete the loop in Python, PHP is running normaly. PHP: <html> <head> <title>PHP</title> </head> <body> <?php shell_exec('sudo python /home/pi/blink.py 1); ?> </body> </html> Python: #!/usr/bin/env python import RPi.GPIO as GPIO import time import sys GPIO.setmode(GPIO.BCM

Calling a endless Python script from PHP

。_饼干妹妹 提交于 2020-03-05 06:18:02
问题 I have a PHP script that calls a python script. Both running on the same Linux server. The Python script is running in a "while true" loop. Now when I start the PHP script, it remains in an endless loop and never ends. If i delete the loop in Python, PHP is running normaly. PHP: <html> <head> <title>PHP</title> </head> <body> <?php shell_exec('sudo python /home/pi/blink.py 1); ?> </body> </html> Python: #!/usr/bin/env python import RPi.GPIO as GPIO import time import sys GPIO.setmode(GPIO.BCM

Do - while goes into an infinite loop

不羁岁月 提交于 2020-02-23 07:16:08
问题 Im trying to add an input validation to this menu. When the user enters eg: 'a' or any input that is not a integer and with the given range, it must execute the catch block and loop again to prompt the user to enter again but instead it keeps looping infinitely after taking the input once. So it goes from executing the menu and just skipping over the input part and executes the catch block. Edit: it goes into infinite loop if i input anything that is not an integer. Scanner sc = new Scanner

Javascript continue statement in while loop causes an infinite loop

倾然丶 夕夏残阳落幕 提交于 2020-02-03 16:24:43
问题 I'm trying to create a while loop with a continue statement. However it seems to be causing an infinite loop and I can't figure out why. The code below to me seems like it should start with the var tasksToDo at 3 then decrement down to 0 skipping number 2 on the way. var tasksToDo = 3 while (tasksToDo > 0) { if (tasksToDo == 2) { continue; } console.log('there are ' + tasksToDo + ' tasks'); tasksToDo--; } 回答1: conitnue , will go back to the while loop. and tasksToDo will never get decremented

Javascript continue statement in while loop causes an infinite loop

ぐ巨炮叔叔 提交于 2020-02-03 16:24:08
问题 I'm trying to create a while loop with a continue statement. However it seems to be causing an infinite loop and I can't figure out why. The code below to me seems like it should start with the var tasksToDo at 3 then decrement down to 0 skipping number 2 on the way. var tasksToDo = 3 while (tasksToDo > 0) { if (tasksToDo == 2) { continue; } console.log('there are ' + tasksToDo + ' tasks'); tasksToDo--; } 回答1: conitnue , will go back to the while loop. and tasksToDo will never get decremented

Check if a list is made up of N instances of X (repeat X N times)

心已入冬 提交于 2020-01-30 08:58:09
问题 Given a query such as: containsN(4,2,Z). I should get: Z = [2,2,2,2]. or containsN(4,W,[3,3,3,3]) I should get: W = 3. So in other words, for the first example I need 4 instances of 2 in a list bound to Z. For the second example I need the element in the list applied 4 times bound to W. My attempt so far results in an infinite loop: containsN(Y,W,Z) :- contains_helper(Y,W,Z). contains_helper(0,_,_). contains_helper(Y,W,[H|T]) :- W = H, Y0 is Y - 1, contains_helper(Y0,W,T). The idea is, I call

Check if a list is made up of N instances of X (repeat X N times)

余生颓废 提交于 2020-01-30 08:58:04
问题 Given a query such as: containsN(4,2,Z). I should get: Z = [2,2,2,2]. or containsN(4,W,[3,3,3,3]) I should get: W = 3. So in other words, for the first example I need 4 instances of 2 in a list bound to Z. For the second example I need the element in the list applied 4 times bound to W. My attempt so far results in an infinite loop: containsN(Y,W,Z) :- contains_helper(Y,W,Z). contains_helper(0,_,_). contains_helper(Y,W,[H|T]) :- W = H, Y0 is Y - 1, contains_helper(Y0,W,T). The idea is, I call

Why is this code an infinite loop?

戏子无情 提交于 2020-01-23 23:59:58
问题 Before completing this code, I just tested it by mistake and realized that it will not stop: $var = "any"; for ($i=1; $i < 2; $i++){ $var.$i = "any"; } Why does this produce an infinite loop? And why doesn't PHP produce an error? 回答1: I did a simple test : echo $i; $var.$i = "any"; var_dump($var); Result : 1string(3) "any" anzstring(3) "any" So $i get transformed to "anz" and doesn't pass the validation to get out of the loop. $var.$i = "any"; is not really correct, i don't know what you are

java stackoverflowerror thrown in infinite loop

空扰寡人 提交于 2020-01-22 02:15:30
问题 I have the following function that starts a jsvc daemon for receiving UDP messages: @Override public void start() throws Exception { byte[] buf = new byte[1000]; DatagramPacket dgp = new DatagramPacket(buf, buf.length); DatagramSocket sk; sk = new DatagramSocket(1000); sk.setSoTimeout(0); byte[] rcvMsg = null; run(sk, dgp, rcvMsg); } With a timeout of 0, the socket blocks until a another message comes in. This is what triggers the continuous run through the following while loop:

How is a StackOverflowException detected?

旧时模样 提交于 2020-01-19 06:42:10
问题 TL;TR When I asked the question I assumed a StackOverflowException is a mechanism to prevent applications to run infinitely. This is not true. A StackOverflowException is not being detected. It is thrown when the stack does not have the capacity to allocate more memory. [Original question:] This is a general question, which may has different answers per programming language. I am unsure how languages other than C# process a stack overflow. I was going through exceptions today and kept