infinite-loop

PyUnit - How to unit test a method that runs into an infinite loop for some input?

我的未来我决定 提交于 2019-12-04 01:46:42
问题 A post in 2011 answered this question for NUnit: How to unit test a method that runs into an infinite loop for some input? Is there a similar TimeoutAttribute in PyUnit that I can use in the same fashion? I did some searching and found "Duration", but that didn't seem the same. 回答1: There doesn't appear there is anything in pyunit itself, but as a work around you can roll your own. Here is how to do it using the multiprocessing package. from functools import wraps from multiprocessing import

Limiting execution time of embedded Python

夙愿已清 提交于 2019-12-04 01:21:35
If I embed the Python interpreter in a C or C++ program, as in this example , is there any way to limit how long the interpreter runs for? Is there anything to stop the Python code from entering an infinite loop and thus preventing PyObject_CallObject (or equivalent) from ever returning? Similarly, if the Python code creates a new thread, is there anything to stop this thread from entering an infinite loop and running forever? Peter Brittain As you can see in the docs , PyObject_CallObject has no mechanism for limiting how long the function runs. There is also no Python C API function that I

Stopping an infinite loop on a remote server PHP

那年仲夏 提交于 2019-12-03 19:47:56
问题 I have a simple infinite for loop looking like this: set_time_limit (0); for (;;) { ... //Doing some stuff including to write to a file sleep(300); } It's running on my server. (Shared hosting account) How on earth can I stop it? 回答1: kill the process. assuming you can get access to the console via ssh and your server runs on linux: ps -ef | grep php // to get a list of php-processes kill [process-id] // kill the process by process-id 回答2: You might want to contact your hosting service and

Why my FB app loops forever in IE?

北慕城南 提交于 2019-12-03 17:20:25
I have a Facebook app which loops forever when run in IE. In other browsers it works fine. I need your help to debug this, but before that I need to mention how I have implemented it. FB recommends that when user tries to access the app we should redirect the user to the app authorization page. From there FB will redirect (using 302 code) to an url which we like. In this case I ask FB to redirect to my app's url with a flag appLogin=1 in query string. But along with that FB attaches a really long param code in the query string which is quite ugly. So, in this case I put a flag LoggedIn in my

Is there any way to kill a setInterval loop through an Onclick button

喜欢而已 提交于 2019-12-03 16:54:06
问题 So, I got an infinite loop to work in this function using setInterval attached to an onClick. Problem is, I can't stop it using clearInterval in an onClick. I think this is because when I attach a clearInterval to an onClick, it kills a specific interval and not the function altogether. Is there anything I can do to kill all intervals through an onClick? Here's my .js file and the calls I'm making are input type="button" value="generate" onClick="generation(); input type="button" value=

NodeJS memory consumption in an infinite loop

大城市里の小女人 提交于 2019-12-03 16:14:19
问题 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)

Spring Boot - infinite loop service

时光怂恿深爱的人放手 提交于 2019-12-03 15:44:23
I want to build a headless application which will query the DB in infinite loop and perform some operations in certain conditions (e.g. fetch records with specific values and when found launch e-mail sending procedure for each message). I want to use Spring Boot as a base (especially because of Actuator to allow expose health-checks), but for now I used Spring Boot for building REST web-services. Is there any best practices or patterns to follow when building infinite loop applications ? Does anyone tried to build it based on Spring Boot and can share with me his architecture for this case ?

Switch statement within while loop in C

丶灬走出姿态 提交于 2019-12-03 15:06:59
There are several postings concerning switch statements within while loops, except for the fact that none of them are done in C, at least from what I've seen. C++ can create boolean expressions, which I'm aware of, but not in C. I have a while loop that contains a switch control. However, when I write break statements within my switch, it goes back to the beginning of the loop and makes my program run forever. Ignore the functions I use, for they work for sure. I just need some clarification on my handling of the nesting. Thanks! Here is my main.c: while(1) { printf("0) Exit\n1) List Tasks\n2)

infinite loop in c++ [duplicate]

a 夏天 提交于 2019-12-03 14:18:49
This question already has answers here : Infinite loop with cin when typing string while a number is expected (4 answers) I'm learning C++ and writing little programs as I go along. The following is one such program: // This program is intended to take any integer and convert to the // corresponding signed char. #include <iostream> int main() { signed char sch = 0; int n = 0; while(true){ std::cin >> n; sch = n; std::cout << n << " --> " << sch << std::endl; } } When I run this program and keep inputs at reasonably small absolute values, it behaves as expected. But when I enter larger inputs,

How can I add a user interrupt to an infinite loop?

妖精的绣舞 提交于 2019-12-03 13:42:58
I have a ruby script below which infinitely prints numbers from 1 onward. How can I make the script stop its infinite execution through an interrupt in the terminal like 'Ctrl+C' or key 'q'? a = 0 while( a ) puts a a += 1 # the code should quit if an interrupt of a character is given end Through every iteration, no user input should be asked. I think you will have to check the exit condition in a separate thread: # check for exit condition Thread.new do loop do exit if gets.chomp == 'q' end end a = 0 loop do a += 1 puts a sleep 1 end BTW, you will have to enter q<Enter> to exit, as that's how